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.
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()
{
}
}
public HorizontalGroupAttribute(float width = 0F, int marginLeft = 0, int marginRight = 0, float order = 0F)
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. |
public HorizontalGroupAttribute(string group, float width = 0F, int marginLeft = 0, int marginRight = 0, float order = 0F)
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. |
public bool DisableAutomaticLabelWidth
public float Gap
public float LabelWidth
public float MarginLeft
public float MarginRight
public float MaxWidth
public float MinWidth
public float PaddingLeft
public float PaddingRight
public string Title
public float Width
protected override void CombineValuesWith(PropertyGroupAttribute other)
PropertyGroupAttribute | other | The other group to combine with. |