Scripts/General
From Unify Community Wiki
Revision as of 07:23, 14 November 2018 by Isaiah Kelly (Talk | contribs)
Scripts | General | Editor | Controllers | UI | Effects | Physics/Simulation | Networking | Audio | Utility |
Contents |
Singletons
- Singleton - Base class you can use to create MonoBehaviour derived singletons by just inheriting from it.
- Singleton Launcher - Uses a prefab to automatically load singleton instances into the scene. No need to crate them manually.
- Secure UnitySingleton - Unity Specific Singleton with a concise interface for creators.
- AutoSingletonManager - Easy and automatic creation of singleton manager objects.
Messaging
- Advanced Messenger - Simple and efficient messaging system implemented with delegates and generics. Allows for logging of messages, has extended error detection, and adds extra protection from unexpected exceptions.
- BroadcasterMessenger - Modified version of Messenger Extended.
- Event Manager - Messaging/notification system. Allows subscription to events without referencing their definitions.
- Messenger - Another messaging/notification system implemented using delegates and generics.
- Messenger Extended - messaging system using delegates and generics. Based on Messenger but has more error detection.
- DelayedDelegates - An easy, central way to call function with a delay
- DelayedMessage - A super simple way to send a message to an object after a number of seconds, and optionally repeat.
- MessageRouter - subscription based messaging with delayed notification, delivery stages, message filtering, tagging, and receiver assertions
- Notification Center - Register scripts to receive and post notifications. Handles messaging across scripts without references to each other.
- NotificationCenterGenerics - A version of Notification Center that has stricter typing.
Input
- Unity_Custom_Input_Manager - Allows you to change input configuration on the fly. Default inputmanager only allows you to change on start.
- KeyboardEventManager - An event-based keyboard input manager.
- IPhoneToMouse - Replaces iPhoneInput commands with Input so you can use it in PC/Mac Version too.
- FingerManager - Easily manage multi-touch phases for iPhone.
Time
- CoroutineScheduler - A coroutine scheduler implementation. Gain a better understanding of coroutines.
- CoroutineHelper - A collection of some helper classes to get easy access to coroutine features for delegates.
- CoUpdate - An alternative to Update which support yield instructions. Benefit from cleaner code.
- CustomFixedUpdate - A class that allows you to create seperate FixedUpdate callbacks are any rate you like.
- UpdatePump - Register any method in any object to be called in one of Unity's update loops.
- SpeedLerp - Replacements for Mathf.Lerp, InverseLerp, SmoothStep, etc. that are typically 1.5X faster or more. Also adds Vector2Lerp and SuperLerp.
- TimeOfDay - Compute the game time into hours, minutes and seconds depending on the duration of a day.
- GeneralTimer - A simple timer component that includes a few extra methods for ease of use.
- QuickTimer - A poll based timer useful in "called on each frame" methods.
- SimpleTimer - A basic non-Monobehaviour timer script that can start and pause.
- AbortableEnumerator - Provides the ability to Stop a Coroutine without calling StopCoroutine.
Math
- CustomRandom - C# Random number generator, when you must have a random number generator that works the same way on all platforms!
- Angle - Helper class to work with angles.
- DirectionFinder - Determines the general direction between two vectors
- Get Aspect Ratio - A simple function that returns an aspect ratio between two values as Vector2.
- HexConverter - Functions for converting decimal colors to hexadecimal... and back.
- Interpolate - Interpolation utility functions for easing, Bezier splines, and Catmull-Rom splines.
- Mathfx - This script contains a growing number of small and useful math functions (short for Mathf eXtended).
- Matrix - A class for doing 3D matrix math against Vector3 objects.
- PolyContainsPoint - Like Rect.Contains, except instead of a rect, you can define any arbitrary polygon.
- QuaternionExtensions - A set of useful extension methods to the inbuilt Quaternion struct.
- SphericalCoordinates - A class to manipulate an object's position with spherical coordinates instead of cartesian.
- UnitSphere - A collection of random unit vector generating functions. (C#)
- ExtRandom - An extension to the Unity class Random
Serialization
- ArrayPrefs - Functions for saving and loading arrays of ints, floats, and strings using PlayerPrefs. (Made obsolete by ArrayPrefs2.)
- ArrayPrefs2 - Faster and better than ArrayPrefs. Save/load Vector2, Vector3, Quaternion, Color as well as a bunch of different array types.
- PlayerPrefsX2 - Extended PlayerPrefs for object. It needs PlayerPrefsX(without 2).
- BoolPrefs - Adds GetBool and SetBool, which are missing from PlayerPrefs.
- CSVReader - A simple script to load CSV files (comma separated data files) into the project.
- LoadSettings - A script for loading settings.txt files into your project, and allowing easy data insertion and debug tests.
- MetadataSystem - Mechanism for ciphered, compressed preferences and declarative metadata system with runtime overrides.
- PlayerSave - Script with the functionality of PlayerPrefs, but lets you specify the save location for each platform.
- PropertyListSerializer - Loads and saves a .plist XML file to and from a hierarchical hashtable.
- SimpleDictionary - Implements a simple dictionary-like object AND lets you save/load the dictionaries to text files.
- TinyXmlReader - A class that reads XML text and parses it for use.
- TinyXmlReaderWeb - TinyXmlReader to use with the web player.
- PrivateFieldWarnings - A shell script to silence warnings about private serialized fields that are not assigned to in code.
Data Structures
- ArrayTools - Functions to use built-in arrays like an ArrayList.
- DeepCopy - Creates a deep copy of an array or hashtable.
- MultiKeyDictionary - Like a Dictionary, but you can have two keys for each elements.
- ObjectCopier - An alternative to IClonable.
- ParallelKeyDictionary - Like a Dictionary, but you can have identical keys.
- ReflectedObject - Reflects a target object, providing quick access by name to reading/writing its fields/properties, and calling its methods.
- Set - A set data structure.
- JavascriptMultiDimArrays - Declare multi-dimensional arrays like int[,] or int[][] in JS (mostly obsolete in Unity 3.2, though still useful for jagged arrays)
- SQLite - How to integrate SQLite into your project.
Strings
- SimpleRegex - How one might use regular expressions in Unity.
- LanguageFilter - Removes badwords from strings using regular expressions.
- MD5 - Generate an MD5 hash for a string.
- ExpressionParser - A simple extensible expression parser that can evaluate mathematical string-expressions.
- StringFilter - A class to allow string filtering based on a list of exclude words / char.
- StringToValue - Functions for finding data within a string.
- StringUtil - Word wrap and line count functions.
- IPhoneDeviceModel - Plugin that return the iPhone Device Model as a string.
- TextScanner - A utility class for parsing strings using std C sscanf format strings.
- SecondsToText - Convert seconds to a text time string using the highest set available.
- TextManager - Uses gettext and PO Editor for translating text.
Texture/Color
- HSBColor - This utility script provides a HSB color model in addition to Unity's built in RGB Color class.
- LABColor - This utility script provides an LAB color model. Lab color is designed to approximate human vision and so it aspires to perceptual uniformity.
- MaxRectsBinPack - A port of Jukka Jylänki's Max Rect algorithm, useful for generating sprite atlases
- MiniEXR - A class that allows writing 16-bit EXR files directly from Unity.
- TextureDrawCircle - A function that draws circles inside a texture.
- TextureDrawLine - A function that draws lines inside a texture.
- TextureFloodFill - A floodfill extension for Texture2D.
- TextureScale - Resize textures, while scaling the contents using either bilinear or point filtering.
- TextureUtils - Functions for colorizing, masking, and merging textures at runtime.
- UnityPaint - A script to draw anti-aliased lines, brush strokes and vector lines on a texture.
- XKCDColors - A collection of 948 color constants, from the xkcd color survey (C#).
- XKCDColorsByIndex - A modified version of XKCDColors, accessible by index rather than name.
Meshes
- FastObjImporter - Fast importer for Blender .obj files at runtime.
- MeshCreationGrid - Shows how to procedurally generate a mesh with proper vertices and uvs to work as a tile-grid
- MeshCreationHelper - Helper to create a new mesh from some mesh's submesh.
- MeshHelper - Helper to subdivide into 2x2 or 3x3 and keep shared vertices / edges.
- MeshMerger - Draw a large number of meshes with a single draw call.
- MeshSmoother - Deformation of a mesh by applying Laplacian/HC-Algorithm Smoother, also script for finding adjacent vertices in a mesh.
- MeshSubdivision - Center and edge subdivision.
- MetaMorph - MetaMorph is a Unity3d and Blender3d toolkit that allows mesh animation in Unity games using Blender shapekeys.
- ObjExporter - A simple utility class for exporting a mesh to an obj file.
- ObjExporterColorUvs - Enhanced version of ObjExporter that also exports vertex color and multiple uvsets to an obj file.
- ObjImporter - Import .obj files at runtime.
- PolyOrderFixupOnImport - Replaces original polygon ordering in a mesh after possible unwanted optimizations by Unity.
- PrintPolyCount - Prints total vertex and triangle count in the object hierarchy.
- ProceduralPrimitives - Codes to procedurally create custom primitive meshes.
- SkinnedMeshTools - Copy one skinnedmesh renderer onto another with same bones. Think swappable equipment pieces.
- Triangulator - A utility class for splitting a 2D polygon into triangles.
- UVTransfer - Editor script to transfer UVs between two models.
- VertexInfo - Displays the vertex numbers of a mesh at the runtime.
Code Snippets
- Accessing number of drawcalls from script - Retrieve the number of drawcalls for statistical purposes
- Calculating Lead For Projectiles - These script fragments allow you to add some lead ahead of the target allowing
- Config loading - A well considered pattern for loading global data. Doesn't require the Resources folder or any scene data.
- Load Data from Excel 2003 - This script allows you to load information from excel spreadsheets into Unity, written in C#.
- Save and Load from XML - This script allows you to save and load data from an XML file, written in C# (JS version included).
- Save and Load from XML U3 Collections - Save and load all game objects in a scene, modify the code to add in what you want saved about the game object, written in C#.
- Low Pass Filter - These functions apply a low pass filter to a Vector3 and a Quaternion value. Useful to get rid of jitter.
- Averaging Quaternions and Vectors - Simple method of averaging rotational values (quaternion) and positions (vector).
- 3d Math functions - This is a collection of generic 3d math functions such as line - plane intersection, closest points on two lines, etc.
- ScaleTransform - A method allows you to scale a GameObject transform to a specific size along the x & z axis by taking into account the GameObjects renderer bounds if a renderer component is attached. Also takes into account any children of the transform.
- Windows Saved Game Directory - Query the path of the Saved Games directory (Vista and up) with fallback to My Documents\My Games on Windows systems.
Utility
- AddChild - Adds an empty GameObject as a child of each selected object.
- Anchor Multi Resolution - Anchor GameObject to specific screen positions. Can be used for GUI as well. Utilize orthographic camera.
- Autorun - Execute some code exactly once, whenever the project is opened, recompiled, or run.
- AutoSave - This script creates a new window in the editor with a autosave function. It is saving your current scene with an interval from 1 minute to 10 minutes.
- BoneDebug - Draws debug bones in a character.
- Bresenham3D - An enumerator that allows you to loop through all integer Vector3's along a line.
- ComponentInstantiationUtility - Static C# class that allows you to instantiate pre-parented components as game objects with one easy line of code.
- deepSearch - Searches recursively from the parent down.
- DrawGizmoGrid - Draws a grid centered on your gameobject using the Gizmos api.
- ExpandoObject - Create ECMAScript-style expando objects in Unity Javascript.
- Google Analytics - A script component that allows for event logging to Google Analytics.
- GuiTextOverParent - Auto tracks a child GuiText over a 2D sprite.
- Interface Finder - A script that will allow you to find classes that implement a certain interface in a scene.
- IsVisibleFrom - An extension method for checking if an Renderer is rendered by a specific Camera.
- IPhone Build Utility Script - This script copies the icon and splash screen every time the project is built.
- JobQueue - A threaded job queue with an internal thread pool.
- LayerMaskExtensions - Extension class to add usability and easier debugging to LayerMasks.
- Layers - A utility script for holding easily-accessible layers and easily creating masks.
- MixupGO - Flatten GameObjects and all attached components into a single object using duck typing in Unity Javascript.
- PrintExtended - Additional print methods.
- RayCastWithoutPhysics - Raycast without pixel color, takes 1/4 of a second to Raycast using Zbuffer.
- ScrollingBG - A simple scrolling class useful for easy 2d paralaxed backgrounds.
- Shell - A replacement for the built-in shell function removed from Unity 1.6.1.
- Simple LOD Manager - Script to handle arbitrary number and distances for Level-Of-Detail in models
- TileSelector - An Inspector extension that creates a pop-up window to select a tile or a NxM group of tiles from a main tileset, for use in a sprite object.
- TitleSafeAreaDisplay - Helper that renders guides for visualizing title safe area.
- WeightedRandomizer - Selects a random element from a collection where each item has a different weight (% chance of being selected). (C#)
- ToggleCapsLock - Checks and sets the state of the caps lock key's toggle.
Miscellaneous
- MazeGenerator - Randomly generates a maze.
- 3DMenu - A simple main menu for 3d text in your scene
- CameraFog - Modifies a camera to allows you to control the fog settings for that camera separately from the global scene fog or other cameras.
- ConstantVelocity - Set a local velocity to an object (useful for missiles perhaps?)
- Cubescape - Simple perlin cube landscape, can be made voxel.
- Flag - Simple bitwise logical operations.
- Flashlight - Allows the switching on and off of a light in script.
- GameObjectLock - A simple script written in C# that can lock a game objects position, rotation or scale independently or set a global lock to prevent those values from changing.
- LevelUp - Provides the basic formula for leveling up characters based on experience points.
- ModularConstruction - Basic general purpose modular building system for Rust-like buildings, or anything else made from modules.
- OldSchoolSteering - Rotate a transform towards 8 axes by assigning a new forward-direction from the horizontal and vertical inputs.
- OnCollideExplode - Spawn a prefab (explosion) on collision, and remove the GameObject from the game.
- OnExplosionEffect - Give an explosive effect over an area.
- OnMouseDown - Sends OnMouseDown messages on an iPhone.
- PointerManager - Hides the mouse pointer when it is not in use.
- SwitchCamera - Switches between cameras in your scene.
- Teleporter - Teleport all objects from one place to another.
- TransformRotation2D - Represent Transform rotations with just a float (useful for 2D games).
- AStarHelper - Textbook implementation of the A* pathing routine.
- ClassTypeReference - Serializable reference to
System.Type
for class types with custom property drawer and attributes to filter selection for editor interfaces. - EnumeratedDelegate - A method to setup a quick and dirty Finite State Machine of sorts by means of generics, delegates and an enum.
- Executors Framework - A framework for multi-threading without getting a headache. (Warning: The Unity API is not thread-safe)
- FakeGizmoDemo - Simple example of creating a fake Gizmo that can be applied to an object at runtime, not just in the editor.
- FindingClosestObject - How to find the closest object to the player, defined by layer. Using Physics.OverlapSphere, an IComparer and InvokeRepeating. Script in JS.
- Lipis Runtime Gizmo - Update on Lipis Runtime Gizmo (works with Translation, Rotation, and Scale). Included C# code and corrected javascript code removing unity 3D reserved words in code.
- Lock Free Queue - Queue that can be simultaneously enqueued to and dequeued from, even from multiple threads.
- ToggleGravity - How to toggle a property, in this case the global gravity setting, by the left mouse button.