Unity 4 incoming feature: Property Drawers

Another great feature that will come with Unity 4 is the property attributes/drawers.

By adding specific attributes on your component fields, you can use custom property drawers in the inspector. Look at the image above to see an example of what you can achieve with this system.

This is done in 3 steps:

  1. Define an “attribute class” inheriting from PropertyAttribute where you declare the data you will need (parameters to check the validity of your field, help messages, etc)
  2. Define a “drawer class” inheriting from ProperyDrawer where you define the behavior of the editor (how to display your field, how to validate the value user will input, etc)
  3. Add the attribute to your field with the parameters you defined in step 1

Use can even use it on “Serializable” classes.

More details and source code examples on Unity’s blog post:¬†

 Scroll to top