Class HorizontalLineAttribute
Draws a horizontal separator line immediately above the decorated field in the Unity Inspector, providing a lightweight visual divider between groups of fields.
Inherited Members
Namespace: Scylla.Core.Attributes
Assembly: ScyllaCore.dll
Syntax
[AttributeUsage(AttributeTargets.Field)]
public sealed class HorizontalLineAttribute : PropertyAttribute
Remarks
Use this attribute to create visual section breaks between logically related groups of serialized fields without collapsible grouping behavior. For collapsible groups, use FoldoutAttribute instead. For a larger, labeled section header, use TitleAttribute instead.
The line height is clamped to a minimum of 1 pixel via Mathf.Max(1f, height)
to ensure the line is always visible. RGB color components are clamped to the
[0, 1] range via Mathf.Clamp01. The default appearance is a 1-pixel
dark-gray line matching Unity's standard separator style.
The line does not reserve height for a label and adds only the specified pixel height to the Inspector layout above the decorated field.
public class Settings : MonoBehaviour
{
[SerializeField] private float _playerHealth = 100f;
[SerializeField] private float _playerSpeed = 5f;
/* Default 1px gray separator */
[HorizontalLine]
[SerializeField] private float _enemyHealth = 50f;
/* Thicker 2px separator in a custom dark-red color */
[HorizontalLine(2f, 0.6f, 0.1f, 0.1f)]
[SerializeField] private bool _enableDebug = false;
}
Constructors
HorizontalLineAttribute()
Creates a horizontal separator line with the default appearance: 1 pixel thick and dark gray (RGB 0.35, 0.35, 0.35).
Declaration
public HorizontalLineAttribute()
HorizontalLineAttribute(float)
Creates a horizontal separator line with a custom thickness and the default dark-gray color (RGB 0.35, 0.35, 0.35).
Declaration
public HorizontalLineAttribute(float height)
Parameters
| Type | Name | Description |
|---|---|---|
| float | height | The desired thickness of the line in pixels. Values below 1 are clamped to 1 to ensure the line is always visible. |
HorizontalLineAttribute(float, float, float, float)
Creates a horizontal separator line with a custom thickness and a fully specified RGB color.
Declaration
public HorizontalLineAttribute(float height, float r, float g, float b)
Parameters
| Type | Name | Description |
|---|---|---|
| float | height | The desired thickness of the line in pixels. Values below 1 are clamped to 1 to ensure the line is always visible. |
| float | r | The red component of the line color in the normalized [0, 1] range. Values
outside this range are clamped via |
| float | g | The green component of the line color in the normalized [0, 1] range. Values
outside this range are clamped via |
| float | b | The blue component of the line color in the normalized [0, 1] range. Values
outside this range are clamped via |
Properties
ColorB
Gets the blue component of the separator line color, in the normalized [0, 1] range.
Declaration
public float ColorB { get; }
Property Value
| Type | Description |
|---|---|
| float | A |
Remarks
Values outside [0, 1] are clamped during construction. The default
value is 0.35f, yielding a neutral dark-gray appearance.
ColorG
Gets the green component of the separator line color, in the normalized [0, 1] range.
Declaration
public float ColorG { get; }
Property Value
| Type | Description |
|---|---|
| float | A |
Remarks
Values outside [0, 1] are clamped during construction. The default
value is 0.35f, yielding a neutral dark-gray appearance.
ColorR
Gets the red component of the separator line color, in the normalized [0, 1] range.
Declaration
public float ColorR { get; }
Property Value
| Type | Description |
|---|---|
| float | A |
Remarks
Values outside [0, 1] are clamped during construction. The default
value is 0.35f, yielding a neutral dark-gray appearance.
Height
Gets the height (thickness) of the separator line in pixels.
Declaration
public float Height { get; }
Property Value
| Type | Description |
|---|---|
| float | The line thickness in screen pixels. Minimum value is |
Remarks
Always at least 1 pixel; values below 1 are clamped up to 1 during construction. Larger values produce a thicker, more prominent separator.