Game Development Reference
In-Depth Information
Now, when you return to the editor and move the look-at point or the camera, there will be
a yellow line drawn between them.
Note
If you collapse the script in the Inspector pane, this will turn off the Gizmo. This is handy
if you want to just hide it.
If you don't want the Gizmo drawn all the time, you can also track when the user has the
Gizmo selected using the OnDrawGizmosSelected method, as follows:
void OnDrawGizmosSelected()
{
Gizmos.color = Color.red;
Gizmos.DrawLine(transform.position, cameraTarget);
}
Now when the game object the script is attached to is selected in the editor, the line will
be drawn in red instead of yellow. Alternatively, just use the OnDrawGizmosSelec-
ted function on its own to only draw a line when selected.
Tip
For more information on Gizmos, see the Unity reference guide at ht-
tp://docs.unity3d.com/Documentation/ScriptReference/Gizmos.html .
Search WWH ::




Custom Search