Group Attributes

Have you ever had a very large script with many inspector variables, and found it a little difficult or tedious to keep track of them all in the inspector? Groups in Odin exist to address this problem, and help greatly with keeping your inspector manageable and nice to look at.

What they do lies in the name: groups let you group together related properties, and draw them in any variety of ways, from simple labeled boxes and dropdowns to multi-page tab groups. Using them is easy; simply put group attributes with the same name on the members you want to group together.

[TabGroup("First Tab")]
public int FirstTab;

[ShowInInspector, TabGroup("First Tab")]
public int SecondTab { get; set; }

[TabGroup("Second Tab")]
public float FloatValue;

[TabGroup("Second Tab"), Button]
public void Button()

Pretty cool, but what if you could combine groups together? Well, you can.

[FoldoutGroup("Buttons in Boxes")]
[HorizontalGroup("Buttons in Boxes/Horizontal", Width = 60)]
[BoxGroup("Buttons in Boxes/Horizontal/One")]
public void Button1() { }

[BoxGroup("Buttons in Boxes/Horizontal/Two")]
public void Button2() { }

[BoxGroup("Buttons in Boxes/Horizontal/Double")]
public void Accept() { }

[BoxGroup("Buttons in Boxes/Horizontal/Double")]
public void Cancel() { }

Odin also makes it trivial to add your own group types to the inspector, see the page How To Make A Custom Group for an in-depth guide.

This website is brand new and built with the Odin 2.1 beta in mind. This means you might discover some features such as attribute expressions that are only available in the beta.

You can download the 2.1 beta from here and read the patch-notes here.