Skip to content

Property Drawer vs Editor vs Editor Window and When to Use Them – Unity

The Unity Editor API classes are fairly similar, so it’s worth clarifying their use cases.

Property Drawer

A property drawer is used to create a custom field or create modifiers for a property field. For example, you could create a custom field for an object you frequently use or a Range modifier to limit the which ints or floats can be selected (that’s built actually in).

Editor

An editor is used to create an entire custom editor for a script. You can use this to add logic to your editor (like selectively showing or hiding fields based on settings), indirectly set values (like cast an int field to a string), or even an in editor ping-pong game.

Editor Window

An editor window is used to create a custom editor window. For example, the Ultimate Screenshot Tool and Ultimate Gif Tool create editor windows to take screenshots or create gifs. Editor windows can use multiple objects or scripts to create a behavior that is usually not tied to specific scenes or objects. The Inspector is an example of an Editor Window. You can re-use your Editors in Editor Windows with this trick.

Summary

Generally, the choice of which class to use just comes down to your use case.

Tl;DR: Property drawers are for properties, editors for whole scripts, and editor windows for anything bigger!

Published inCode ExamplesDesign TipsDevelopment Tips

Be First to Comment

    Leave a Reply

    Your email address will not be published. Required fields are marked *