Scripts/General
From Unify Community Wiki
(Difference between revisions)
Isaiah Kelly (Talk | contribs) m (→Singletons) |
Isaiah Kelly (Talk | contribs) (moved many links to development/utility page) |
||
Line 1: | Line 1: | ||
− | {{Scripts | + | {{Scripts Navigation}} |
− | = | + | == Input == |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
*[[KeyboardEventManager]] - An event-based keyboard input manager. | *[[KeyboardEventManager]] - An event-based keyboard input manager. | ||
*[[IPhoneToMouse]] - Replaces iPhoneInput commands with Input so you can use it in PC/Mac Version too. | *[[IPhoneToMouse]] - Replaces iPhoneInput commands with Input so you can use it in PC/Mac Version too. | ||
*[[FingerManager]] - Easily manage multi-touch phases for iPhone. | *[[FingerManager]] - Easily manage multi-touch phases for iPhone. | ||
− | = | + | == Data Structures == |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | = Data Structures = | + | |
*[[ArrayTools]] - Functions to use built-in arrays like an ArrayList. | *[[ArrayTools]] - Functions to use built-in arrays like an ArrayList. | ||
Line 86: | Line 19: | ||
*[[SQLite]] - How to integrate SQLite into your project. | *[[SQLite]] - How to integrate SQLite into your project. | ||
− | = Strings = | + | == Strings == |
*[[SimpleRegex]] - How one might use regular expressions in Unity. | *[[SimpleRegex]] - How one might use regular expressions in Unity. | ||
Line 100: | Line 33: | ||
*[[TextManager]] - Uses [http://en.wikipedia.org/wiki/Gettext gettext] and PO Editor for translating text. | *[[TextManager]] - Uses [http://en.wikipedia.org/wiki/Gettext gettext] and PO Editor for translating text. | ||
− | = Texture/Color = | + | == Texture/Color == |
*[[HSBColor]] - This utility script provides a HSB color model in addition to Unity's built in RGB Color class. | *[[HSBColor]] - This utility script provides a HSB color model in addition to Unity's built in RGB Color class. | ||
Line 115: | Line 48: | ||
*[[XKCDColorsByIndex]] - A modified version of [[XKCDColors]], accessible by index rather than name. | *[[XKCDColorsByIndex]] - A modified version of [[XKCDColors]], accessible by index rather than name. | ||
− | = Meshes = | + | == Meshes == |
*[[FastObjImporter]] - Fast importer for Blender .obj files at runtime. | *[[FastObjImporter]] - Fast importer for Blender .obj files at runtime. | ||
Line 136: | Line 69: | ||
*[[VertexInfo]] - Displays the vertex numbers of a mesh at the runtime. | *[[VertexInfo]] - Displays the vertex numbers of a mesh at the runtime. | ||
− | = | + | == Other == |
*[[Accessing number of drawcalls from script]] - Retrieve the number of drawcalls for statistical purposes | *[[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 | + | *[[Calculating Lead For Projectiles]] - These script fragments allow you to add some lead ahead of the target allowing |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
*[[Low Pass Filter]] - These functions apply a low pass filter to a Vector3 and a Quaternion value. Useful to get rid of jitter. | *[[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). | *[[Averaging Quaternions and Vectors]] - Simple method of averaging rotational values (quaternion) and positions (vector). | ||
Line 149: | Line 78: | ||
*[[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. | *[[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 <tt>Saved Games</tt> directory (Vista and up) with fallback to <tt>My Documents\My Games</tt> on Windows systems. | *[[Windows Saved Game Directory]] - Query the path of the <tt>Saved Games</tt> directory (Vista and up) with fallback to <tt>My Documents\My Games</tt> on Windows systems. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
*[[Bresenham3D]] - An enumerator that allows you to loop through all integer Vector3's along a line. | *[[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. | *[[ComponentInstantiationUtility]] - Static C# class that allows you to instantiate pre-parented components as game objects with one easy line of code. | ||
Line 163: | Line 84: | ||
*[[ExpandoObject]] - Create ECMAScript-style expando objects in Unity Javascript. | *[[ExpandoObject]] - Create ECMAScript-style expando objects in Unity Javascript. | ||
*[[Google Analytics]] - A script component that allows for event logging to Google Analytics. | *[[Google Analytics]] - A script component that allows for event logging to Google Analytics. | ||
− | |||
*[[Interface Finder]] - A script that will allow you to find classes that implement a certain interface in a scene. | *[[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. | *[[IsVisibleFrom]] - An extension method for checking if an Renderer is rendered by a specific Camera. | ||
Line 180: | Line 100: | ||
*[[WeightedRandomizer]] - Selects a random element from a collection where each item has a different weight (% chance of being selected). (C#) | *[[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. | *[[ToggleCapsLock]] - Checks and sets the state of the caps lock key's toggle. | ||
− | |||
− | |||
− | |||
*[[MazeGenerator]] - Randomly generates a maze. | *[[MazeGenerator]] - Randomly generates a maze. | ||
*[[3DMenu]] - A simple main menu for 3d text in your scene | *[[3DMenu]] - A simple main menu for 3d text in your scene |
Latest revision as of 23:45, 14 November 2018
Scripts | General | Editor | Controllers | UI | Effects | Physics/Simulation | Networking | Audio | Utility |
Contents |
[edit] Input
- 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.
[edit] 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.
[edit] 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.
[edit] 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.
[edit] 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.
[edit] Other
- 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
- 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.
- 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.
- 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.
- 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.