Version 3.3.0.1

Odin has a dedicated attribute overview with examples

HorizontalGroupAttribute 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)]
[Conditional("UNITY_EDITOR")]
public class HorizontalGroupAttribute : PropertyGroupAttribute, _Attribute

HorizontalGroup is used group multiple properties horizontally in the inspector.

The width can either be specified as percentage or pixels.

All values between 0 and 1 will be treated as a percentage.

If the width is 0 the column will be automatically sized.

Margin-left and right can only be specified in pixels.

Inheritance
Example

The following example shows how three properties have been grouped together horizontally.

// The width can either be specified as percentage or pixels.
// All values between 0 and 1 will be treated as a percentage.
// If the width is 0 the column will be automatically sized.
// Margin-left and right can only be specified in pixels.

public class HorizontalGroupAttributeExamples : MonoBehaviour
{
    [HorizontalGroup]
    public int A;

    [HideLabel, LabelWidth (150)]
    [HorizontalGroup(150)]
    public LayerMask B;

    // LabelWidth can be helpfull when dealing with HorizontalGroups.
    [HorizontalGroup("Group 1"), LabelWidth(15)]
    public int C;

    [HorizontalGroup("Group 1"), LabelWidth(15)]
    public int D;

    [HorizontalGroup("Group 1"), LabelWidth(15)]
    public int E;

    // Having multiple properties in a column can be achived using multiple groups. Checkout the "Combining Group Attributes" example.
    [HorizontalGroup("Split", 0.5f, PaddingRight = 15)]
    [BoxGroup("Split/Left"), LabelWidth(15)]
    public int L;

    [BoxGroup("Split/Right"), LabelWidth(15)]
    public int M;

    [BoxGroup("Split/Left"), LabelWidth(15)]
    public int N;

    [BoxGroup("Split/Right"), LabelWidth(15)]
    public int O;

    // Horizontal Group also has supprot for: Title, MarginLeft, MarginRight, PaddingLeft, PaddingRight, MinWidth and MaxWidth.
    [HorizontalGroup("MyButton", MarginLeft = 0.25f, MarginRight = 0.25f)]
    public void SomeButton()
    {

    }
}

Constructors

HorizontalGroupAttribute(Single, Int32, Int32, Single)
Organizes the property in a horizontal group.
public HorizontalGroupAttribute(float width = 0F, int marginLeft = 0, int marginRight = 0, float order = 0F)
Parameters
System.Single width

The width of the property. Values between 0 and 1 are interpolated as a percentage, otherwise pixels.

System.Int32 marginLeft

The left margin in pixels.

System.Int32 marginRight

The right margin in pixels.

System.Single order

The order of the group in the inspector.

HorizontalGroupAttribute(String, Single, Int32, Int32, Single)
Organizes the property in a horizontal group.
public HorizontalGroupAttribute(string group, float width = 0F, int marginLeft = 0, int marginRight = 0, float order = 0F)
Parameters
System.String group

The group for the property.

System.Single width

The width of the property. Values between 0 and 1 are interpolated as a percentage, otherwise pixels.

System.Int32 marginLeft

The left margin in pixels.

System.Int32 marginRight

The right margin in pixels.

System.Single order

The order of the group in the inspector.

Fields

DisableAutomaticLabelWidth
Fallback to using the default label width, whatever that might be.
public bool DisableAutomaticLabelWidth
Gap
The width between each column. Values between 0 and 1 will be treated as percentage, otherwise pixels.
public float Gap
LabelWidth
The label width, 0 = auto.
public float LabelWidth
MarginLeft
The margin left. Values between 0 and 1 will be treated as percentage, 0 = ignore, otherwise pixels.
public float MarginLeft
MarginRight
The margin right. Values between 0 and 1 will be treated as percentage, 0 = ignore, otherwise pixels.
public float MarginRight
MaxWidth
The maximum Width. Values between 0 and 1 will be treated as percentage, 0 = ignore, otherwise pixels.
public float MaxWidth
MinWidth
The minimum Width. Values between 0 and 1 will be treated as percentage, 0 = ignore, otherwise pixels.
public float MinWidth
PaddingLeft
The padding left. Values between 0 and 1 will be treated as percentage, 0 = ignore, otherwise pixels.
public float PaddingLeft
PaddingRight
The padding right. Values between 0 and 1 will be treated as percentage, 0 = ignore, otherwise pixels.
public float PaddingRight
Title
Adds a title above the horizontal group.
public string Title
Width
The width. Values between 0 and 1 will be treated as percentage, 0 = auto, otherwise pixels.
public float Width

Methods

CombineValuesWith(PropertyGroupAttribute)
Merges the values of two group attributes together.
protected override void CombineValuesWith(PropertyGroupAttribute other)
Parameters
PropertyGroupAttribute other

The other group to combine with.