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:
- 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)
- 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)
- 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: http://blogs.unity3d.com/2012/09/07/property-drawers-in-unity-4/