Scripts

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
(Camera Controls)
(added introduction and contributions sections)
 
(388 intermediate revisions by more than 100 users not shown)
Line 1: Line 1:
== Camera Controls ==
+
{{Scripts Navigation}}
  
*[[CrossFade]] - Smoothly fade the view from one camera to another.
+
== Introduction ==
*[[RectangleWipe]] - Make an animated rectangular zooming screen wipe from one camera to another.
+
In this section you'll find a large assortment of sample scripts and code snippets contributed by members of the community. These can be accessed by selecting one of the category tabs above.
*[[ShapeWipe]] - Make an animated screen wipe, where an arbitrary shape containing the second view zooms in or out, and rotates.
+
*[[SquishWipe]] - Make an animated screen wipe from one camera to another, where the first image is squished out of view.
+
*[[Headbobber]] - This script makes an object bob up and down smoothly when you're pressing one or both of the horizontal/vertical axes.
+
*[[MouseLookPlus]] - A javascript mouselook with key control. based on the standard assets C# mouselook.
+
*[[SmoothFollow2]] - This is designed to make a camera smoothly follow a ship in space.
+
*[[FadeInOut]] - Little script to fade a full-screen image in or out, good for fade in outs.
+
  
== Character Controller Scripts ==
+
=== Contributions ===
 +
Anyone is free to contribute their own original code to the wiki but you should keep a few things in mind when doing so:
  
*[[Force2D]] - Place this script on a [http://www.otee.dk/Documentation/ScriptReference/GameObject.html GameObject] and have it constrained to two dimensions.
+
# '''No Copyrighted Content''' - Code contributed must be either original or licensed in a way which allows sharing (e.g. public domain, open-source, etc.).
*[[ShipControls]] - Place this script on a [http://www.otee.dk/Documentation/ScriptReference/Rigidbody.html RigidBody] for 2D spaceship controls like [http://otee.dk/gallery/udwc/OverWhelmedArena.html OverWhelmed Arena].
+
# '''Keep It Concise''' - Small scripts and code snippets are ideal. More complex code should be hosted on a platform like [https://bitbucket.org/ Bitbucket] or [https://github.com/ GitHub] instead.
*[[VariableSpeedFPSwalker]] - An FPS walker script having different speeds for walking forward, strafing, and backpedaling
+
# '''Use Proper Formatting''' - Please read the [[Help:Formatting| formatting help page]] before creating a new script. This will explain how to properly format and structure your code.
*[[RigidbodyFPSWalker]] - An physics based FPS walker that works with rigidbodies and thus is affected by forces, joints or other rigidbodies
+
*[[PhysicsFPSWalker]] - Another physics based fps walker script
+
  
== Debugging Scripts ==
+
=== License ===
 
+
Unless otherwise specified, all code provided on the Wiki is licensed under Creative Common's Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0).
*[[DebugConsole]] - A script to allow scrolling feedback from your scripts.
+
*[[UUnit]] - a Simple xUnit framework that can be run inside Unity.
+
*[[Reporter]] - a simple delayed action system info script that could be used for support purposes
+
*[[DetectLeaks]] - a simple GUI script for displaying the amount of objects currently loaded by type
+
*[[DebuggerX]] - A simple javascript singleton that allows you to send debug to the console or the GUI
+
 
+
== General Concepts ==
+
 
+
*[[BasicDataStructures]] - discussion on the use of the data-structures available in unity.
+
*[[AManagerClass]] - example on how to add easy access to a singleton class in a scene.
+
*[[SimpleRegex]] - example of how one might use regular expressions in Unity to do something useful.
+
*[[ToggleGravity]] - example how to toggle a property, in this case the global gravity setting, by the left mouse button.
+
 
+
== General Purpose Effect Scripts ==
+
 
+
*[[TimeBasedTrailRenderer]] - The Built in trail renderer does not fade its segments based on the time they have been alive. This one does.
+
*[[CameraFacingBillboard]] - Use this script on a billboard or similar object to make it align itself with the camera.
+
*[[LookAtCameraYonly]] - Use this script on a billboard or other object to have it face the camera but only rotate on the Y axis.
+
*[[StopEmittingAfterDelay]] - After a configurable delay, particles will fade naturally, then finally the object will get destroyed with autodestruct.
+
*[[Perlin Noise]] - Noise functions for smoothly moving objects around or anything else
+
*[[Animating Tiled texture]] - A texture made of many tiles animated through setting the uv offsets
+
*[[Animating Tiled texture - Extended]] - Use one animation cell-sheet texture for many animations and skins.
+
*[[Character Shadow]] - Cast shadows from an object! ''(requires Unity Pro)''
+
*[[Fog Layer]] - Lets you determine per camera if fog should be enabled or disabled
+
*[[CameraRenderSettings]] - Allows storing seperate render settings per camera - an extended version of the Fog Layer script above.
+
*[[ReverseNormals]] - Reverses normals & back face culling of a mesh
+
*[[MeshMorpher]] - A Mesh Morpher script with scripting API
+
*[[MetaBalls]] - 3D Metaballs
+
*[[Shadow Volumes in Alpha]] - Shadow volume based shadows ''(requires Unity Pro)''
+
*[[SoftBodies]] - Cloth, Springy Noodles, Jello Blocks, etc..
+
*[[Flocking]] - A flocking script with randomness and target following.
+
*[[Spline Controller]] - Interpolates any GameObject along a user-defined spline
+
 
+
== Graphical User Interface Scripts ==
+
 
+
*[[Custom_2D_Pointer]] - Make a custom pointer that changes shape at the edges of the screen.
+
*[[Box_Script]] - Use this system to easily make simple GUI elements in nice looking boxes with buttons that actually do something useful. All generated at runtime from a MenuStyle.
+
*[[Button]] - Use this script on a guiTexture object for regular push buttons that send a message when clicked.
+
*[[DraggableGUIElement]] - Click and drag on GUITexture or GUIText to move it around the screen.
+
*[[FadeIn]] - Allows you to show/hide a [http://www.otee.dk/Documentation/ScriptReference/GUIText.html GUIText] or [http://www.otee.dk/Documentation/ScriptReference/GUITexture.html GUITexture] when pressing a key/button.
+
*[[ForwardAllMouseEvents]] - Send mouse events to some sort of controller type GameObject.
+
*[[GUIFly]] - Use this script on an object to make it respond to a "Fly" message so that it may move on and off the screen in a pleasing manner.
+
*[[GuiRatioFixer]] - Use on a [http://otee.dk/Documentation/ScriptReference/GUIText.html GUIText] /[http://otee.dk/Documentation/ScriptReference/GUITexture.html GUITexture]  object to automatically adjust aspect ratio
+
*[[GuiRatioFixer2]] - Alternate script based on screen's aspect to use on a [http://otee.dk/Documentation/ScriptReference/GUIText.html GUIText] /[http://otee.dk/Documentation/ScriptReference/GUITexture.html GUITexture] object to automatically adjust aspect ratio
+
*[[ToggleButton]] - Extends the Button class to create a toggle button.
+
*[[DragSlider]] - Use this script with a pair of [http://otee.dk/Documentation/ScriptReference/GUITexture.html GUITexture]s to make a functioning slider.
+
*[[TakeScreenshot]] - Captures sequentially numbered screenshots when a function key is pressed.
+
*[[ScreenShotMovie]] - Captures a screenshot sequence for use when making a movie
+
*[[GetTimeString]] - A simple function that can be placed anywhere and used to display times. Useful for racing games.
+
*[[GUIBuilder]] - Generic classes for easing the pain of GUI creation. (BETA)
+
*[[AutoType]] - Automaticly types a string of text typewriter style.
+
 
+
== Unity 2.0 GUI Scripts ==
+
*[[PasswordField]] - Allows the user to type in a field masked by *'s (or any other character)
+
*[[WithPrefs]] - Functions that change values and modifies preferences in one simple step
+
*[[PauseMenu]] - Standard pause menu used by Fugu Games for web players and widgets
+
*[[GUICam]] - Holds GUIRect a rectanle of camera pixelRect in GUI oriented co-oridinates (0,0) is top left
+
*[[CustomGetMouseButtonDown]] - custom wrapper functions for Input.GetMouseButton(Down) which can be modified to block clicks when over a window
+
*[[GUIx]] - extended GUI functions
+
*[[Blinking Text Entry Cursor]] - Make your cursor blink on input fields
+
 
+
== Heads Up Display Scripts ==
+
 
+
*[[MessageDisplayer]] - Use this script on a [http://unity3d.com/Documentation/Components/class-GuiText.html GUIText] object to have a self-disappearing list of status messages.
+
*[[FramesPerSecond]] - Use this script on a [http://unity3d.com/Documentation/Components/class-GuiText.html GUIText] object to display FPS counter.
+
 
+
== Image Postprocessing Effects (require Unity Pro) ==
+
 
+
*[[BloomEffect]] (OBSOLETE) - Sometimes referred to as "glow", use this effect to make bright parts in your scene bleed.  This script is made obsolete by the GlowEffect shipped with Unity 1.5.
+
*[[BoostColors]] - A very simple and fast way to boost the contrast of saturation of the graphics in your game.
+
*[[InvertCamera]] - A simple script that will invert everything rendered by a camera.
+
 
+
== Sound Scripts ==
+
 
+
*[[JukeboxController]] - A very basic jukebox class. This can be used to manage multiple audio clips across different levels.
+
*[[SmoothAudioFade]] - A script for creating smooth audio fades at the push of a button.
+
*[[SmoothAudioLoop]] - A script that allows for audio files with extended "tails" to be looped.
+
 
+
== Performance Scripts ==
+
 
+
*[[StaticPerformanceOptimization]] - A script that optimizes performance statically based on the users graphics card by dropping terrain resolution and quality settings
+
 
+
== WWW Scripts ==
+
 
+
*[[VersionCheck]] - A very basic version checker. This can be used to check if the version of the game the user is running is the latest, and if not, send them to a URL to download the latest.
+
*[[MeshSerializer]] - Save Unity meshes to files for the Web, load them with WWW interface.
+
*[[CookieCutter]] - Access browser cookies from Unity web players.
+
*[[PlayerPrefsx]] - An extension to CookieCutter which allows you to save data in both standalones and cookies for the web without having to think about it.
+
*[[UnityObject]] - A nice & clean way to embed .unityweb in your web browser. Plugin Detection, Communication, Clean HTML
+
*[[GetXMLHack]] - Get XML data into the web player using browser script instead of WWW() (which has been buggy for me!)
+
*[[Server Side Highscores]] - A complete tutorial for implementing a server side php script for storing high scores and how to post the scores to the server.
+
 
+
== Unity 1.x Networking Scripts ==
+
 
+
*[[NetworkCursor]] - Serverless realtime networking. An example where one Unity instance controls another via a TCP/IP socket. Could be expanded to do many types of realtime networking.
+
*[[Server]] - TCP network host, based on NetworkCursor, but expanded to do more.
+
*[[Sender]] - Uses a Server to send data from the parent object to whatever is on the other end of the connection.
+
*[[Simple TCP/IP Client - Server]] - This contains source code for C# that you can use to create a server for Windows and a DLL in C# that you can use with Unity
+
 
+
== Physics Scripts ==
+
 
+
*[[DontGoThroughThings]] - Script that uses raycasting to avoid fast-moving objects going through obstructions.
+
 
+
== Editor Scripts ==
+
*[[AddChild]] - Adds an empty GameObject as a child of each selected object.
+
*[[AddComponentRecursively]] - Adds a component to an object, and all the children of that object.
+
*[[CopyTransform]] - Copies the local transform of the selected game instance in the scene and then pastes it into another one you select.
+
*[[DeleteComponentsInChildren]] - Helps to delete a special type of components which are attached to the children of the selected Gameobject.
+
*[[FindObjects]] - Find objects by name or attached component type.
+
*[[GetSize]] - Get the size in game units of a selection.
+
*[[InsertParent]] - An alternative to the built-in Make Parent command, this script inserts a new GameObject which becomes the parent of all selected objects.
+
*[[Notes]] - Allows you to add notes to any GameObject.
+
*[[PixelLightMapper]] - A pixel based light mapper for Unity
+
*[[SnapToGrid]] - Snaps objects to a grid in 3 dimensions.
+
*[[Take3DScreenshot]] - Take a "3d screenshot"; a series of screenshots captured while rotating around a given object. Useful for QTVR creation.
+
*[[ToggleActiveRecursively]] - Activates/deactivates entire hierarchies at once.
+
 
+
== Utility Scripts ==
+
 
+
*[[HSBColor]] - This utility script provides a HSB color model in addition to Unity's built in RGB Color class.
+
*[[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
+
*[[ObjExporter]] - A simple utility class for exporting a mesh to an obj file
+
*[[TerrainObjExporter]] - Export Unity 2.0 Terrain objects as obj files
+
*[[HexConverter]] - Functions for converting decimal colors to hexadecimal... and back.
+
*[[StringToValue]] - Functions for finding data within a string.
+
*[[ExpandoObject]] - Create ECMAScript-style expando objects in Unity Javascript
+
*[[MixupGO]] - Flatten GameObjects and all attached components into a single object using duck typing  in Unity Javascript
+
*[[PrintPolyCount]] - Prints total vertex and triangle count in the object hierarchy.
+
*[[TextScanner]] - A utility class for parsing strings using std C sscanf format strings
+
*[[Layers]] - A utility script for holding easily-accessible layers and easily creating masks
+
*[[StringUtil]] - Word wrap and line count functions.
+
*[[Shell]] - A replacement for the built-in shell function removed from Unity 1.6.1
+
*[[Set]] - A set data structure.
+
*[[MD5]] - Generate an MD5 hash for a string
+
*[[VertexInfo]] - Displays the vertex numbers of a mesh at the runtime
+
*[[deepSearch]] - Searches recursively from the parent down
+
*[[CustomRandom]] - C# Random number generator, when you must have a random number generator that works on all platforms and runtimes .net runs on!
+
*[[MazeGenerator]] - Randomly generates a maze
+
* [[Angle]] - Helper class to work with angles
+
 
+
== Simulation Scripts ==
+
*[[SICK Laser Scanner]] - This script simulates the SICK LMS type planar laser scanner
+
*[[IMU Inertial Measurement Unit]] - This script simulates an IMU providing velocities and accelerations of the object it is attached to in the objects local frame.
+
*[[GPS Global Positioning System]] - This script simulates a GPS device providing real world GPS locations based on a reference point
+
*[[Compass]] - This script simulates a compass with North relative to the Z axis of a reference object
+
*[[GameTime]] - This script rotates a directional light to match the rotation of the sun based on the system time.
+
*[[Gravity]] - Simulates body-to-body gravity (i.e. planetary gravity)
+
*[[Trajectory Simulation]] - Demonstrates simulating the trajectory of a launched object
+
 
+
== Really Simple Scripts ==
+
*[[SwitchCamera]] - This script switches between cameras in your scene.
+
*[[ConstantVelocity]] - This script allows you to set a local velocity to an object (useful for missiles perhaps?)
+
*[[OnCollideExplode]] - This script spawns a prefab(explosion) on collision, and removes the gameobject from the game.
+
*[[OnCollideSound]] - This script spawns a prefab(preferably a sound) if a collision is over a certain magnitude.
+
*[[OnExplosionEffect]] - This script attached to an explosion will give an area effect of an explosion
+
 
+
== Code Snippets ==
+
 
+
*[[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 - A quadratic rather than an iterative solution
+

Latest revision as of 20:29, 14 November 2018

Scripts   General   Editor   Controllers   UI   Effects   Physics/Simulation   Networking   Audio   Utility

[edit] Introduction

In this section you'll find a large assortment of sample scripts and code snippets contributed by members of the community. These can be accessed by selecting one of the category tabs above.

[edit] Contributions

Anyone is free to contribute their own original code to the wiki but you should keep a few things in mind when doing so:

  1. No Copyrighted Content - Code contributed must be either original or licensed in a way which allows sharing (e.g. public domain, open-source, etc.).
  2. Keep It Concise - Small scripts and code snippets are ideal. More complex code should be hosted on a platform like Bitbucket or GitHub instead.
  3. Use Proper Formatting - Please read the formatting help page before creating a new script. This will explain how to properly format and structure your code.

[edit] License

Unless otherwise specified, all code provided on the Wiki is licensed under Creative Common's Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0).

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox