Skip to content

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;
Movement
Speed
5.00
Accel
2.00
Friction
0.50

[Header("Text")]

Renders a small subsection label above the field.

[Header("Linear")]
public float Speed = 5.0f;
Linear
Speed
5.00

[Divider] and [Space]

[Divider] inserts a horizontal rule before the field. [Space(8f)] inserts vertical padding.

public float Above = 1.0f;
[Divider]
public float Below = 2.0f;
Above
1.00
Below
2.00

[DisplayName("Custom")] and [Units("m/s")]

[DisplayName] overrides the auto-generated label. [Units] appends a unit suffix.

[DisplayName("Forward speed")]
[Units("m/s")]
public float ForwardSpeed = 0.5f;
Forward speed(m/s)
0.50

[Tooltip("...")]

Hover-help text that appears on the field or button after a short delay.

[Tooltip("Forward speed in metres per second.")]
public float ForwardSpeed = 0.5f;
Forward Speed
0.50
Forward speed in metres per second.

Numeric ranges and validation

[Slider(min, max)]

Renders the field as a horizontal slider. Ctrl+Click to type a value, double-click to reset.

[Slider(0.0f, 1.0f)]
public float Friction = 0.5f;
Friction
0.50

[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.

[ClampValue(0.0f, 100.0f)]
[Units("kg")]
public float Mass = 10.0f;
Mass(kg)
10.00

Widget replacement

[ToggleButton("On", "Off")]

Replaces the default checkbox with a full-width labelled button on bool fields.

[ToggleButton("Active", "Paused")]
public bool Running = true;
value: true
Running
Active
value: false
Running
Paused

Renders an int field as a combo box. The stored value is the selected index.

[Dropdown("Idle", "Walk", "Run")]
public int State = 1;
State

[Bitmask("Read", "Write", "Exec")]

Renders an int field as a multi-select combo. Each label maps to a bit.

[Bitmask("Read", "Write", "Exec")]
public int Permissions = 0b011;  // Read | Write
Permissions

[Multiline(rows: 4)]

Renders a string field as a multi-line text area.

[Multiline(rows: 4)]
public string Notes = "";
Notes
Multi-line text area…

[ColorPreview]

Renders a Vector3 or Vector4 field as a colour picker with a swatch and RGB / HSV / hex inputs.

[ColorPreview]
public Vector4 Tint = new Vector4(0.96f, 0.31f, 0.24f, 1.0f);
Tint
RGBA 0.96, 0.31, 0.24, 1.00

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);
UseCustomColor = false
Use Custom Color
Off
Custom Color
RGBA 1.00, 1.00, 1.00, 1.00
UseCustomColor = true
Use Custom Color
On
Custom Color
RGBA 1.00, 1.00, 1.00, 1.00

[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.

[ReadOnly]
public float ComputedSpeed = 0.0f;
Computed Speed
0.00

[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;
}
 
Reset position

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;
Locomotion
Forward Speed(m/s)
0.50

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.