Unity Attributes

Changing the way things appear in the Inspector.

Unity has a variety of Property Attributes you can use to make the inspector easier to use by customize the way it appears in the inspector.

The Ship and The Player Behaviors could really use some help. Everything is all bunched up together and it is hard to see each of the different Values.

The Header attribute

You can organize your variables together by putting the [Header] attribute.

This will create a Header before the variable is rendered in the inspector.

Notice that you can put several Attributes on the same line and they can be on the same line as the variable deceleration.

The Space Attribute

You can add some space in the inspector with the [Space] attribute.

Now for the Confusing Part. When Combined with the Header Attribute if you put [Space][Header] will actually add space after the Header and [Header][Space] will add space before the Header.


By adding the [Header] and [Space] attributes you can easily make the inspector look a little more presentable.

These are not the only attributes that you can use. There are many more including [SerializedField] [Range] [ToolTip] [TextArea] [MultiLine][ColorUsage] and [ContextMenuItem]. Unity also has Attributes that you can add to the class like [SelectionBase] [AddComponentMenu] or [DisallowMultipleComponent]. You can take a look at the Unity Scripting API to see more information about them.

There are a lot of them.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store