PropertyGroupAttribute class

Namespace: Sirenix.OdinInspector
Assembly: Sirenix.OdinInspector.Attributes
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Parameter | AttributeTargets.Delegate | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter | AttributeTargets.All, AllowMultiple = true, Inherited = true)]
public abstract class PropertyGroupAttribute : Attribute, _Attribute

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


Note that this attribute has special behaviour for "combining" several attributes into one, as one group, may be declared across attributes in several members, completely out of order. See CombineValuesWith(PropertyGroupAttribute).

  • System.Object
  • System.Attribute
  • PropertyGroupAttribute

All group attributes for a group with the same name (and of the same attribute type) are combined into a single representative group attribute using the CombineValuesWith(PropertyGroupAttribute) method, which is called by the Combine(PropertyGroupAttribute) method.

This behaviour is a little unusual, but it is important that you understand it when creating groups with many custom parameters that may have to be combined.


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, float 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;


Initializes a new instance of the PropertyGroupAttribute class.
public PropertyGroupAttribute(string groupId)
System.String groupId

The group identifier.

PropertyGroupAttribute(String, Single)
Initializes a new instance of the PropertyGroupAttribute class.
public PropertyGroupAttribute(string groupId, float order)
System.String groupId

The group identifier.

System.Single order

The group order.


Whether to animate the visibility changes of this group or make the visual transition instantly. True by default.
public bool AnimateVisibility
The ID used to grouping properties together.
public string GroupID
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.
public string GroupName
Whether to hide the group by default when all its children are not visible. True by default.
public bool HideWhenChildrenAreInvisible
The order of the group.
public float Order
If not null, this resolved string controls the group's visibility. Note that if HideWhenChildrenAreInvisible is true, there must be *both* a visible child *and* this condition must be true, before the group is shown.
public string VisibleIf



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; }

public PropertyGroupAttribute Combine(PropertyGroupAttribute other)
PropertyGroupAttribute other

The attribute to combine with.


The instance that the method was invoked on.


The argument 'other' was null.


Attributes to combine are not of the same type. or PropertyGroupAttributes to combine must have the same group id.


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.

protected virtual void CombineValuesWith(PropertyGroupAttribute other)
PropertyGroupAttribute other

The attribute to combine with. This parameter is guaranteed to be of the correct attribute type.