-
Book Overview & Buying
-
Table Of Contents
Extending Unity with Editor Scripting
By :
We explored how to add simple gizmos through the Unity editor. This section will cover how to properly implement the OnDrawGizmos and OnDrawGizmosSelected methods to achieve a similar but more flexible solution.
All the scripts in this section are examples, and are not meant to be used in the Level Creator tool.
To get started, in a new project, create a script called GizmoExample.cs. We will use this as a guinea pig for our first gizmos experiments (don't worry, the script is not going to suffer too much!)
Write the following code in GizmoExample.cs:
using UnityEngine;
public class GizmoExample : MonoBehaviour {
private void OnDrawGizmos() {
}
}When you implement the OnDrawGizmos method, you can add gizmos that always drawn in the Scene View and also allows the possibility to be selected with a click.
In this case, the method is empty. However, if you come back to Unity and wait for the compiler...
Change the font size
Change margin width
Change background colour