Posted on Leave a comment

Unity Property Drawer Attributes

The Unity editor is a really useful tool when making a game. A lot of its power comes from how customizable it is. If you want to make a new window to do some custom action it is as easy as writing code like you would for the game. Custom inspectors and property drawers are the most common form of customization. These work in the inspector to simplify working with your components.

There are preexisting property drawer attributes you can use to simplify your inspector. Recently, I wanted to find if there was one I could use for a script I was working on. Unfortunately there wasn’t a comprehensive list of attributes built in to Unity. So I went ahead and made a list for future reference.


Since 4.0
This changes a float or int to a slider. The parameters are the lowest and highest allowed values.

[Range(0, 100.5f)]
public float range;
[Range(0, 5)]
public int moreRange;
[Range(0, 10)]
public float[] rangeArray;


Since 4.0
Changes a string to use multiple lines in the input field. The optional parameter is the number of lines.

public string multiline;
public string moreMultiline;
public string[] multilineArray;


Since 4.5
Changes a string to a multiple line text area with scroll bars when the text doesn’t fit.

public string textArea;
[TextArea(3, 6)]
public string moreTextArea;
public string[] textAreaArray;

There are other attributes which do not alter behavior or appearance I will likely go over later.

Leave a Reply

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