O'Reilly logo

Extending Unity with Editor Scripting by Angelo Tadres

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a custom inspector

In this section, we will create the base structure to start using custom inspectors in our project.

Using the CustomEditor attribute

The CustomEditor attribute is part of the UnityEditor namespace and is the way Unity binds an editor script with a specific type of the MonoBehaviour class to modify the way the default inspector works.

Note

To use the CustomEditor attribute, you must place your script inside an Editor folder, or in a folder nested inside an Editor folder.

Create a script called LevelInspector.cs inside the folder Tools\LevelCreator\Editor, and then add the following code:

using UnityEngine; using UnityEditor; namespace RunAndJump.LevelCreator { [CustomEditor(typeof(Level))] public class LevelInspector : Editor ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required