Version 3.3.1.2

OdinGroupDrawer<TGroupAttribute> class

Namespace: Sirenix.OdinInspector.Editor
Assembly: Sirenix.OdinInspector.Editor
public abstract class OdinGroupDrawer<TGroupAttribute> : OdinDrawer where TGroupAttribute : PropertyGroupAttribute

Base class for all group drawers. Use this class to create your own custom group drawers. OdinGroupDrawer are used to group multiple properties together using an attribute.

Note that all box group attributes needs to inherit from the PropertyGroupAttribute

Remember to provide your custom drawer with an Sirenix.OdinInspector.Editor.OdinDrawerAttribute in order for it to be located by the .

Inheritance
  • System.Object
  • OdinDrawer
  • OdinGroupDrawer<TGroupAttribute>
Remarks

Checkout the manual for more information.

Example
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public class MyBoxGroupAttribute : PropertyGroupAttribute
{
    public MyBoxGroupAttribute(string group, float order = 0) : base(group, order)
    {
    }
}

// Remember to wrap your custom group drawer within a #if UNITY_EDITOR condition, or locate the file inside an Editor folder.

public class BoxGroupAttributeDrawer : OdinGroupDrawer<MyBoxGroupAttribute>
{
    protected override void DrawPropertyGroupLayout(InspectorProperty property, MyBoxGroupAttribute attribute, GUIContent label)
    {
        GUILayout.BeginVertical("box");
        for (int i = 0; i < property.Children.Count; i++)
        {
            InspectorUtilities.DrawProperty(property.Children[i]);
        }
        GUILayout.EndVertical();
    }
}

// Usage:
public class MyComponent : MonoBehaviour
{
    [MyBoxGroup("MyGroup")]
    public int A;

    [MyBoxGroup("MyGroup")]
    public int B;

    [MyBoxGroup("MyGroup")]
    public int C;
}

Type Parameters

TGroupAttribute

Constructors

OdinGroupDrawer()
protected OdinGroupDrawer()

Properties

Attribute
public TGroupAttribute Attribute { get; }

Methods

CanDrawGroup(InspectorProperty)
protected virtual bool CanDrawGroup(InspectorProperty property)
Parameters
InspectorProperty property

Returns
System.Boolean

CanDrawProperty(InspectorProperty)
public override sealed bool CanDrawProperty(InspectorProperty property)
Parameters
InspectorProperty property

Returns
System.Boolean

DrawPropertyLayout(GUIContent)
Draws the property with GUILayout support.
protected override void DrawPropertyLayout(GUIContent label)
Parameters
UnityEngine.GUIContent label

The label. This can be null, so make sure your drawer supports that.

Extension Methods