HorizontalGroupAttribute

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.

namespace Sirenix.OdinInspector
{
[AttributeUsageAttribute((AttributeTargets)448, AllowMultiple = True, Inherited = True)]
public class HorizontalGroupAttribute : PropertyGroupAttribute
}

Requirements

Namespace: Sirenix.OdinInspector
Assembly: Sirenix.OdinInspector
Version: 1.0.4.1

See Also

Constructors

Definition Description
HorizontalGroupAttribute(float, int, int, int) Organizes the property in a horizontal group.
HorizontalGroupAttribute(string, float, int, int, int) Organizes the property in a horizontal group.

Properties

Return Type Definition Description
float MarginLeft The margin left. Values between 0 and 1 will be treated as percentage, 0 = ignore, otherwise pixels.
float MarginRight The margin right. Values between 0 and 1 will be treated as percentage, 0 = ignore, otherwise pixels.
float MaxWidth The maximum Width. Values between 0 and 1 will be treated as percentage, 0 = ignore, otherwise pixels.
float MinWidth The minimum Width. Values between 0 and 1 will be treated as percentage, 0 = ignore, otherwise pixels.
float PaddingLeft The padding left. Values between 0 and 1 will be treated as percentage, 0 = ignore, otherwise pixels.
float PaddingRight The padding right. Values between 0 and 1 will be treated as percentage, 0 = ignore, otherwise pixels.
string Title Adds a title above the horizontal group.
float Width The width. Values between 0 and 1 will be treated as percentage, 0 = auto, otherwise pixels.

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()
    {

    }
}