Attribute to derive from if you wish to create a new property group type, such as box groups or tab groups.


namespace Sirenix.OdinInspector
[AttributeUsageAttribute((AttributeTargets)32767, AllowMultiple = True, Inherited = True)]
public abstract class PropertyGroupAttribute : Attribute


Namespace: Sirenix.OdinInspector
Assembly: Sirenix.OdinInspector

See Also


Return Type Definition Description
string GroupID The ID used to grouping properties together.
string GroupName The name of the group. This is the last part of the group ID if there is a path, otherwise it is just the group ID.
int Order The order of the group.


Definition Description
PropertyGroupAttribute(string) Initializes a new instance of the PropertyGroupAttribute class.
PropertyGroupAttribute(string, int) Initializes a new instance of the PropertyGroupAttribute class.


Return Type Definition Description
PropertyGroupAttribute Combine(PropertyGroupAttribute)

Combines this attribute with another attribute of the same type. This method invokes the virtual CombineValuesWith(PropertyGroupAttribute) method to invoke custom combine logic.

All group attributes are combined to one attribute used by a single OdinGroupDrawer.


protected override void CombineValuesWith(PropertyGroupAttribute other) { this.Title = this.Title ?? (other as MyGroupAttribute).Title; }

void CombineValuesWith(PropertyGroupAttribute)

Override this method to add custom combine logic to your group attribute. This method determines how your group's parameters combine when spread across multiple attribute declarations in the same class.

Remember, in .NET, member order is not guaranteed, so you never know which order your attributes will be combined in.


This example shows how BoxGroupAttribute could be implemented.

[AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = true)]
public class BoxGroupAttribute : PropertyGroupAttribute
    public string Label { get; private set; }
    public bool ShowLabel { get; private set; }
    public bool CenterLabel { get; private set; }

    public BoxGroupAttribute(string group, bool showLabel = true, bool centerLabel = false, int order = 0)
        : base(group, order)
        this.Label = group;
        this.ShowLabel = showLabel;
        this.CenterLabel = centerLabel;

    protected override void CombineValuesWith(PropertyGroupAttribute other)
        // The given attribute parameter is *guaranteed* to be of type BoxGroupAttribute.
        var attr = other as BoxGroupAttribute;

        // If this attribute has no label, we the other group's label, thus preserving the label across combines.
        if (this.Label == null)
            this.Label = attr.Label;

        // Combine ShowLabel and CenterLabel parameters.
        this.ShowLabel |= attr.ShowLabel;
        this.CenterLabel |= attr.CenterLabel;