Unity Attributes

Changing the way things appear in the Inspector.

James Lafritz
3 min readApr 10, 2021

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.

Conclusion

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.

--

--

James Lafritz

Excited about changing my hobby into a new carer with GameDevHQ course.