Game Development Reference
In-Depth Information
As mentioned earlier, many Unity objects, such as colliders, trigger volumes,
NavMesh Agents, cameras, and lights, already offer their own visual aids and
gizmos when they are selected. These are shown by default in the Scene viewport
unless you switch them off or reduce their size to zero. So, if you've added a native
Unity object and don't see a gizmo in the Scene viewport, then be sure to check the
Gizmo panel that is accessible from the Scene toolbar via the Gizmo button. Enable
all the gizmos you want to see and adjust the Size slider that increases or decreases
the gizmo size (choose a size that is best for you), as shown here:
Enabling gizmos in the Scene view
Gizmos in the Game tab
Gizmos don't show by default in the Game tab. You can, however,
change this behavior easily using the Gizmo button in the top-right
corner of the Game tab toolbar. This menu works just like the Gizmos
menu for the Scene tab, as shown in the preceding screenshot.
Consider the following code sample 2-6. This is a sample class that can be attached
to an object and it relies on the Unity gizmo class to draw a custom range of
helper gizmos. More information can be found online at http://docs.unity3d.
com/ScriptReference/Gizmos.html . Here, this sample class draws a bounding
wireframe sphere of a specified radius centered on the object that represents its
range of attack. In addition, it draws a line-of-sight vector that represents the object's
forward direction, providing a visual indication of the way the object is facing. All
of these gizmos are drawn inside the OnDrawGizmos event of MonoBehaviour on the
condition that the variable DrawGizmos is true :
 
Search WWH ::




Custom Search