Implement OnDrawGizmos
if you want to draw gizmos that are also pickable and always drawn. This allows you to quickly pick important objects in your scene. You can also use OnDrawGizmos
to draw the line or different types of Gizmos
, such as Gizmos.DrawRay
, Gizmos.DrawLine
, Gizmos.DrawWireSphere
, and so on, which will make it easier for you to debug.
var target : Transform; // Draw the blue line from this object to the target function OnDrawGizmos () { if (target != null) { Gizmos.color = Color.Blue; Gizmos.DrawLine(transform.position, target.position)
The methods mentioned earlier can be referenced from the following Unity Scripting Reference:
http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.Awake.html
http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.Start.html
http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.Update.html
http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.FixedUpdate.html
http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.LateUpdate.html
http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.OnGUI.html
http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.OnDrawGizmos.html
http://unity3d.com/support/documentation/ScriptReference/Gizmos.DrawLine.html
3.144.30.178