Game Development Reference
In-Depth Information
Gizmos 


With custom editors, you could also have handles to represent a control in the scene view,
extending the Inspector features in to the scene.
We also have another way to have class-based features that are only available in the editor
through the use of Gizmos.
Gizmos offer a much richer graphical way to add visual elements to the scene to aid the
use of a class, unlike custom editors, which are only added to your base class that the edit-
or will then make use of.
Note
OnDrawGizmo functions are only available on classes that are derived from MonoBe-
havior , not the Editor classes.
For example, we can amend the CameraLookAt script we created earlier and make it
draw a Gizmo line from the camera to the target's look-at point by adding the following
code to the script:
void OnDrawGizmos()
{
Gizmos.color = Color.yellow;
Gizmos.DrawLine(transform.position, cameraTarget);
}
The code produces the result as follows:
Search WWH ::




Custom Search