Scripts/General

From Unify Community Wiki
Jump to: navigation, search
General   Editor   Controllers   GUI   Effects   Physics / Simulation   Networking   Sound   Development

Contents

General Concepts

  • AutoSingletonManager - Easy and automatic creation of singleton manager objects.
  • AManagerClass - How to add easy access to a singleton class in a scene.
  • AStarHelper - Textbook implementation of the A* pathing routine.
  • BasicDataStructures - Discussion of the use of the data-structures available in Unity.
  • ClassTypeReference - Serializable reference to System.Type for class types with custom property drawer and attributes to filter selection for editor interfaces.
  • 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.
  • 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 - a three-arrow axis, mouse-moveable, that can be applied to an object at Runtime, not just during editing. Also contains an example of Procedural Mesh Creation - using only code to create an in-game mesh object from vertices and triangles.
  • FindingClosestObject - How to find the closest object to the player, defined by layer. Using Physics.OverlapSphere, an IComparer and InvokeRepeating. Script in JS.
  • JavascriptMultiDimArrays - Declare multi-dimensional arrays like int[,] or int[][] in JS (mostly obsolete in Unity 3.2, though still useful for jagged arrays)
  • 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.
  • Secure UnitySingleton - Unity Specific Singleton with a concise interface for creators.
  • SimpleRegex - How one might use regular expressions in Unity.
  • SQLite - How to integrate SQLite into your project.
  • ToggleGravity - How to toggle a property, in this case the global gravity setting, by the left mouse button.
  • ExpressionParser - A simple extensible expression parser that can evaluate mathematical string-expressions.


Messaging Systems

  • Advanced CSharp Messenger - Simple and efficient C# messaging system implemented with delegates and generics. Allows for logging of messages, has extended error detection, and adds extra protection from unexpected exceptions.
  • BooMessenger - An efficient and simple to use messaging platform. Allows hierarchial grouping of message types.
  • BroadcasterMessenger - Modified version of Messenger Extended.
  • CSharpEventManager - C# implementation of a messaging/notification system. Allows subscription to events without referencing their definitions.
  • CSharpMessenger - Another C# messaging/notification system implemented using delegates and generics.
  • CSharpMessenger Extended - C# messaging system using delegates and generics. Based on CSharpMessenger 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
  • NotificationCenter - Register scripts to receive and post notifications. Handles messaging across scripts without references to each other. (See also NotificationCenterGenerics for a version that has stricter typing.)
  • CSharpNotificationCenter - C# implementation of the "NotificationCenter" script. Register scripts to receive and post notifications. Handles messaging across scripts without references to each other.
  • CustomFixedUpdate - A class that allows you to create seperate FixedUpdate callbacks are any rate you like.


Utility Scripts

  • 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.
  • CustomRandom - C# Random number generator, when you must have a random number generator that works the same way on all platforms!
  • 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.
  • ExtRandom - An extension to the Unity class Random
  • FingerManager - Easily manage multi-touch phases for iPhone.
  • GeneralTimer - A simple timer component that includes a few extra methods for ease of use.
  • 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.
  • IPhoneToMouse - Replaces iPhoneInput commands with Input so you can use it in PC/Mac Version too.
  • IPhone Build Utility Script - This script copies the icon and splash screen every time the project is built.
  • IPhoneDeviceModel - Plugin that return the iPhone Device Model as a string.
  • KeyboardEventManager - An event-based keyboard input manager.
  • LanguageFilter - Removes badwords from strings using regular expressions.
  • LayerMaskExtensions - Extension class to add usability and easier debugging to LayerMasks.
  • Layers - A utility script for holding easily-accessible layers and easily creating masks.
  • MazeGenerator - Randomly generates a maze.
  • MD5 - Generate an MD5 hash for a string.
  • MixupGO - Flatten GameObjects and all attached components into a single object using duck typing in Unity Javascript.
  • PlaySoundAtInterval - Plays a sound file at the specified intervals of time.
  • PrintExtended - Additional print methods.
  • QuickTimer - A poll based timer useful in "called on each frame" 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
  • Startup Manager - A singleton class that handles starting up scripts in a sorted order based on a priority variable
  • 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.
  • TextManager - Uses gettext and PO Editor for translating text.
  • TextScanner - A utility class for parsing strings using std C sscanf format strings.
  • 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.
  • Unity_Custom_Input_Manager - Allows you to change input configuration on the fly. Default inputmanager only allows you to change on start.
  • WeightedRandomizer - Selects a random element from a collection where each item has a different weight (% chance of being selected). (C#)

Data Structure Utils

  • 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.


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.

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.

Mesh Helpers

  • 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.

Math Helpers

  • 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.
  • SpeedLerp - Replacements for Mathf.Lerp, InverseLerp, SmoothStep, etc. that are typically 1.5X faster or more. Also adds Vector2Lerp and SuperLerp.
  • 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#)


Really Simple Scripts

  • 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.
  • OnCollideSound - Spawn a prefab (preferably a sound) if a collision is over a certain magnitude.
  • 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.
  • SimpleTimer - A basic non-Monobehaviour timer script that can start and pause.
  • SecondsToText - Convert seconds to a text time string using the highest set available.
  • SwitchCamera - Switches between cameras in your scene.
  • Teleporter - Teleport all objects from one place to another.
  • TimeOfDay - Compute the game time into hours, minutes and seconds depending on the duration of a day.
  • TransformRotation2D - Represent Transform rotations with just a float (useful for 2D games).
  • UpdatePump - Register any method in any object to be called in one of Unity's update loops.

Code Snippets

  • AbortableEnumerator - Provides the ability to Stop a Coroutine without calling StopCoroutine.
  • 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 projectiles/missiles to collide with the target. Uses a quadratic rather than an iterative solution.
  • 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.
  • SingletonLauncher Singleton Launcher
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox