Editor Attributes¶
Editor attributes decorate a script's fields and methods to control how they appear in
the editor Inspector. They are plain C# attributes from the Hazel namespace, applied
directly above a field:
[Tooltip("How fast the entity moves.")]
[Slider(0.0f, 10.0f)]
[Units("m/s")]
public float Speed = 5.0f;
A field with no attributes still appears in the Inspector with a default widget. Attributes refine that default by adding a tooltip, a slider, a clamped range, a custom label, a collapsible group, conditional visibility, or a different widget entirely.
The full list lives in the Editor Attributes reference. This page introduces each category, shows what the attributes render as, and the common patterns.
The mockups below are approximate
The Inspector previews on this page are HTML approximations of the editor's look. They convey shape and behaviour rather than every pixel.
Layout and labelling¶
[Group("Name")]¶
Wraps contiguous fields with the same group name in a collapsible section.
[Group("Movement")] public float Speed = 5.0f;
[Group("Movement")] public float Accel = 2.0f;
[Group("Movement")] public float Friction = 0.5f;
[Header("Text")]¶
Renders a small subsection label above the field.
[Divider] and [Space]¶
[Divider] inserts a horizontal rule before the field. [Space(8f)] inserts vertical
padding.
[DisplayName("Custom")] and [Units("m/s")]¶
[DisplayName] overrides the auto-generated label. [Units] appends a unit suffix.
[Tooltip("...")]¶
Hover-help text that appears on the field or button after a short delay.
Numeric ranges and validation¶
[Slider(min, max)]¶
Renders the field as a horizontal slider. Ctrl+Click to type a value, double-click to reset.
[ClampValue(min, max)], [Min(v)], [Max(v)]¶
[ClampValue] is a two-bound clamp on the drag widget. [Min] and [Max] are
single-bound clamps and compose with each other.
Widget replacement¶
[ToggleButton("On", "Off")]¶
Replaces the default checkbox with a full-width labelled button on bool fields.
[Dropdown("A", "B", "C")]¶
Renders an int field as a combo box. The stored value is the selected index.
[Bitmask("Read", "Write", "Exec")]¶
Renders an int field as a multi-select combo. Each label maps to a bit.
[Multiline(rows: 4)]¶
Renders a string field as a multi-line text area.
[ColorPreview]¶
Renders a Vector3 or Vector4 field as a colour picker with a swatch and RGB / HSV /
hex inputs.
Conditional display¶
The referenced field must be a bool. Both attributes accept Invert = true to flip
the gate.
[EditCondition("OtherField")]¶
The field is read-only when OtherField is false.
public bool UseCustomColor = false;
[EditCondition("UseCustomColor")]
[ColorPreview]
public Vector4 CustomColor = new Vector4(1, 1, 1, 1);
[HideCondition("OtherField")]¶
The field is hidden completely when OtherField is true.
Visibility and access¶
Hidden fields are still serialised.
[ReadOnly]¶
Greys out the field. The value cannot be edited but still appears.
[HideFromEditor] and [ShowInEditor("Label")]¶
[HideFromEditor] hides a public field. [ShowInEditor] surfaces a non-public field.
[HideFromEditor]
public float InternalState = 0.0f;
[ShowInEditor("Cached robot")]
private RobotControllerComponent? m_Robot;
Action buttons¶
[Button("Label")]¶
Renders a method as a clickable button. Defaults to runtime-only (disabled outside play
mode); set RuntimeOnly = false to allow editor-time clicks.
[Button("Reset position")]
public void ResetPosition()
{
Translation = Vector3.Zero;
RotationQuat = Quaternion.Identity;
}
Composing attributes¶
Attributes stack. A single field can carry layout, validation, widget, and conditional attributes at once:
[Group("Locomotion")]
[Tooltip("Walker forward speed.")]
[Slider(0.0f, 1.5f)]
[Units("m/s")]
public float ForwardSpeed = 0.5f;
The Inspector renders fields in declaration order, so the order in the source file determines the order on screen.
The full set¶
Every attribute is documented individually in the
Editor Attributes reference, including
[AllowedAssetTypes], [NoClear], [DisplayPriority], the [ColorPreview] options
(HDR, Alpha), and the [ToggleButton] colour states.