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

Improving the inspector without custom inspectors

In this section, we will explore a way to create custom GUI for our properties using Property Drawers.

What is a Property Drawer?

A Property Drawer allows you to control how the GUI of a Serializable class or property is displayed in the Inspector window. This approach significantly reduces the amount of work you have to do for the GUI customization because you don't need to write an entire custom inspector. Instead, you can just apply appropriate attributes to variables in your scripts to tell the editor how you want those properties to be drawn.

Unity has several built-in Property Drawers. In the following example, we will use the Range attribute:

using UnityEngine; public class DrawerExample : ...

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