O'Reilly logo

Unity 3 Game Development HOTSHOT by Jate Wittayabundit

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

OnDrawGizmos

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.

Note

OnDrawGizmos will use a mouse position that is relative to the Scene view.

Example

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)
 

Reference

The methods mentioned earlier can be referenced from the following Unity Scripting Reference: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required