Create: 2/2/2013 Last Updated: 6/9/2014
this.gameObject.GetComponent<AudioSource>().Play()
this.doorAnimation = this.GetComponentsInChildren<Transform>().FirstOrDefault(t => t.name=="RotationPoint").animation;
Authored: 3/30/2013 Last Updated: 3/30/2013
Emits light in a spherical area around a point source (e.g. candlelight)
Emits a light in a cone
An infinitely large light source positioned an infinitive distance away that projecting an parallel wall of light in a specific direction (e.g. sun). Shadows from a Directional source therefore do not change in size or direction. The location of the directional light object doesn't matter unless (for example) you are adding a lens flare to the object
Applies a inverse-mask (black-block, white allow) to the light source. For example, the famous bat sign or venetian blinds.
One use for Ambient light is to prevent shadows being too sharp (for example, if the only light illuminating the scene is a directional light).
Authored: 3/30/2013 Last Updated: 4/7/2013
Must return IEnumerator not IEnumerable
Time in seconds it took to complete the last frame. Useful to show scale movement (position += speedPerSecond * Time.delatTime), calculate FPS, etc.
Returns the fixed framerate
Same as Update, but since OnGui can be called multiple times per per frame it should not be used outside of a guarded if such as "if(Event.current.type == EventType.repaint") . Consider a coroutine instead.
Authored: 3/30/2013 Last Updated: 5/19/2014
Event.current.type shows why the GUI has been called. For example, drawing code can be made to only run once per frame by placing it inside ' if(Event.current.type == EventType.repaint)'
Authored: 3/30/2013 Last Updated: 3/30/2013
http://cgcookie.com/unity/cgc-series/noob-to-pro-shader-writing-for-unity-4-beginner/(http://docs.unity3d.com/Documentation/Components/SL-Reference.html)
The name of the shader as it will appear in Unity's dropdowns. If it contains a slash (e.g. Custom/Grayscale) Unity will nest the menu option.
Properties needed by the shader. Note lines are unterminated. Also, there must be a corresponsing uniform line in the CGPROGRAM section in order for a property to be avaliable to CGPROGRAM code.
e.g; _Color("Color", Color) = (1.0,1.0,1.0,1.0)
??Target platform
Allows multiple passes over the rendered item. Optional. Unity supports up to 8 passes.
CG is nVidia produced standard (stuff before was Unity specific - aka ShaderLab)
Unity does not require the uniform keyword, but it's the correct syntax for declaring a var in CG.
float4 = 3 part vector such as (x,y,z,w) or (r,g,b,a)
Structs are DTOs for communication betwee vertex and fragment function. Unlike C# struct declarations, these must be semi-colon terminated.
struct myVertexInput { float4 myInputPosition : POSITION; float3 myNormal : NORMAL; ... };
struct myVertexOutput { float4 myOutputPosition : SV_POSITION; (SV_POSTION = DX11 change, otherwise same as POSITION) ... };
Per vertex functionality
myVertexOutput myVirtexFunc(myVertexInput v) { vertixOutput o; // Doesn't need initialization? o.pos = mul(UNITY_MATRIX_MVP, v.vertex); // UNITY_MATRIX_MVP = float4. Multiples x,y,w,z seperately return o; }
Per pixel functionality
#pragma vertex somefuncat the top of the CGPROGRAM section tell the shader which functions is the Vertex function.
#pragma fragment somefuncat the top of the CGPROGRAM section tell the shader which functions is the fragmentfunction.
float4 myFragFunc(vertexOutput i) : COLOR { return myColor; }
Name of shader (e.g. Diffuse) to fallback to if the above is not supported by the platform / graphic card. If not fallback is speciifed, result is pink.
http://docs.unity3d.com/Documentation/Components/SL-BuiltinValues.html
Authored: 3/30/2013 Last Updated: 3/30/2013
Authored: 3/30/2013 Last Updated: 3/30/2013
Tips from Unity3d WIKI
Meshes
Authored: 4/7/2013 Last Updated: 4/7/2013
public void OnTriggerEnter(Collider item) { if(!item.CompareTag("MainCamera")) return; this.IsOpen = true; this.animation.Play("Open"); this.audio.Play(); }
Authored: 4/7/2013 Last Updated: 4/14/2013
The Any State state in the animator controller is effectively a global OR. Instead of having to apply a transition from every state to (say) the death State, a single transition from the Any State to the death State achieves the same thing.
Layers run in parallel. Top layer wins. Unchanged / masked area populate from below. Example uses: Waving, shouting, jumping, etc.
private IEnumerator PlayAnimationOnceCoRoutine(string parameterName) { this.animator.SetBool(parameterName, true); yield return null; this.animator.SetBool(parameterName, false); } public void PlayAnimationOnce(this MonoBehaviour behavior, string parameterName) { if (animator != null) this.StartCoroutine(this.PlayAnimationOnceCoRoutine(parameterName)); }
Authored: 4/13/2013 Last Updated: 4/13/2013
Generates a mesh collider from the import. Off by default
Swaps primary and secondry UV channels. Use if lightmapping is screwed up
???
Authored: 6/14/2014 Last Updated: 6/14/2014
Picture-in-picture
Authored: 4/13/2013 Last Updated: 4/13/2013
Distance at and under which the sound plays at full volume
Distance at and over which the sound plays at lowest volume. If the curve is not zero at the end, this will not be silent
How 3D the sound is. With a level of zero, sound is 2D
Imaging a 5.1 speaker with the user in the center and a sound in the game being emitted from in front of the player. Spread is then the angle of a wedge projecting from the player forwards over which the sound would be spread. 0 means no spread, 360 would project the sound as enclosing the player.
Authored: 3/30/2013 Last Updated: 4/13/2013
Authored: 6/7/2014 Last Updated: 6/7/2014
Authored: 6/7/2014 Last Updated: 6/7/2014
Authored: 6/7/2014 Last Updated: 6/14/2014
Vector3
Authored: 6/9/2014 Last Updated: 6/9/2013
Action | Target |
---|---|
Trigger | |
Replace | |
Activate | |
Enable | Sets the Enable property of the Target object to true |
Animate | Plays Target animation clip on object the script is attached to |
Deactivate | Sets the Enable property of the Target object to false |
Authored: 4/28/2013 Last Updated: 6/8/2013