In this chapter, you learned about how to use gizmos and continued working with the features of the Level Creator tool by implementing a gizmo grid with an snap to grid feature.
The Gizmos class is part of the
UnityEngine namespace and allows you to create visual aids in the Scene View to work with our scripts.
To render gizmos, we must implement the
OnDrawGizmosSelected methods in our
MonoBehaviour classes, and call methods of the Gizmos class to draw the visuals. When it is not possible to access the code of the
MonoBehaviour class to implement these methods directly, an alternative way is to use the
DrawGizmo attribute, allowing you to implement the gizmo logic in a second class.
When you work with gizmos, you can change they color and the matrix used to be rendered. To achieve this, you need to overwrite the variables
Gizmos.matrix, respectively. Because these variables are static, it's recommended to always save the current value of the variables...