Unity Gizmos
Many Unity developers when they are starting out or for that matter even after they are proficient in Unity, they may never come across / never use it.Gizmos are really powerful debugging tools that are provided in Unity and they run in the scene view of the editor. Iteration times (implementing something & testing ) can really be improved a lot because you able to interact with the scene in way that is custom fit to your needs and requirements.
I usually use Gizmos to make a prototype before I make a prototype, which I'm sure a lot of you do.
As Gizmos runs in the editor scene view and because it comes featured with a lot of debugging tools right out of the box, I don't have to implement my own.
To make custom Gizmos you have to write it in the 'OnDrawGizmos' or 'OnDrawGizmosSelected' functions. These are just like the Start() & Update() functions that are there.
The OnDrawGizmos function is called every frame in the editor whereas the OnDrawGizmosSelected function is called only when the specified component is selected in the scene view.
Vertices & Edges Shown Of A Procedural Mesh |
Almost all of the built-in components in Unity have their own custom Gizmos that is shown in the editor.
Like the AudioSource component with it's audio range sphere around it or the spotlight that shows the direction and radius of the light.
Spotlight Gizmo In Unity |
- DrawLine :- Draws a line between two Vector3s.
- DrawRay :- Draws a ray from a point and extends out in a particular direction.
- DrawCube :- Draws a cube at specified point with certain dimensions.
- DrawSphere :- Draws a sphere at certain point with a specified radius.
- Color :- Sets the colour that the rest of the following Gizmos will use.
Support Bitshift Programmer by leaving a like on Bitshift Programmer Facebook Page and be updated as soon as there is a new blog post.
If you have any questions that you might have about shaders or unity development in general don't be shy and leave a message on my facebook page or down in the comments.