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;
In short
Every public field of a supported type appears on the script's Script component in
the Inspector, labelled with its C# name. Attributes add tooltips, ranges, sliders,
groups, conditional visibility or a different widget, and [Button] turns a method
into a button. Numeric fields are number boxes that you drag or type into.
The full list lives in the Editor Attributes reference. This page explains which fields appear, how to edit them, and what each attribute does.
Which fields appear¶
A field appears in the Inspector when it is public and has one of these types:
| Kind | Types |
|---|---|
| Numbers | sbyte, byte, short, ushort, int, uint, long, ulong, float, double |
| Text and toggles | string, bool |
| Vectors | Vector2, Vector3, Vector4 |
| References | Entity, Prefab, Mesh, StaticMesh, Material, Texture2D, Scene |
| Arrays | One-dimensional arrays of any type above |
Fields are listed in declaration order, so the order in the source file is the order on
screen. Properties, enums, Quaternion, component types such as
RobotControllerComponent, and lists are never shown. To show a non-public field, use
[ShowInEditor].
The label is the C# field name exactly as written: a field named ForwardSpeed appears
as ForwardSpeed. Use [DisplayName] for a friendlier
label.
Editing script fields¶
Number fields are number boxes. Drag left or right to change the value, holding Shift
for finer steps or Ctrl for coarser ones. Click without dragging to type a value,
then press Enter or click away to apply it, or Esc to cancel. Tab applies it and
moves to the next field, ready to type if that is a number box too; Shift+Tab moves
back. Typed values can be arithmetic, such as 0.5*3 or d2r(90). A plain float or
double field drags in steps of 0.1, and integer fields always stay whole numbers.
Editing Values describes the number box and its expressions in
full.
- Vector fields show one number box per axis. Click an axis badge to reset that axis to 0.
- Reference fields (
Entity,Prefaband the asset types) show the name of what they point to, or Null. Click one to open a picker beside it: type to narrow the list, then click an item, or use the arrow keys and Enter. Clear empties the field. AnEntityfield lists the scene's entities, and you can also drag an entity onto it from the Scene Hierarchy. Outside arrays, reference fields are greyed out while the scene plays. Asset fields describes the picker. - Array fields show a Length box with - and + buttons, then one row per
element ([0], [1], ...). Except in
boolarrays, each row has an x button that removes the element. Widget attributes such as[Slider],[Dropdown]and[ColorPreview]do not apply to array elements. - Filter fields..., the search box above the fields, hides every field whose C# name does not contain the text you type.
- Reset to default, in a field's right-click menu, restores the value from the field's initialiser in the script.
Changing a number, bool, string or vector field in the Inspector also writes the new
value into that field's initialiser in the script's .cs file, adding an initialiser if
the field has none. After the next build, the new value is the script's default for the
field.
Layout and labelling¶
[Group("Name")]¶
Wraps contiguous fields with the same group name in a collapsible section. Groups start
open. Add DefaultOpen = false to start one collapsed.
[Group("Movement")] public float Speed = 5.0f;
[Group("Movement")] public float Accel = 2.0f;
[Group("Movement")] public float Friction = 0.5f;
[Header("Text")]¶
Shows a dimmed label above the field.
[Divider] and [Space]¶
[Divider] inserts a horizontal line before the field. [Space] inserts vertical
padding before it: 8 pixels by default, or the height you pass, as in [Space(16f)].
[DisplayName("Custom")] and [Units("m/s")]¶
[DisplayName] replaces the label, which is otherwise the C# field name. [Units] adds
the unit to the label in parentheses. It changes only the label, not the value.
This field is labelled Forward speed (m/s). With [Units] alone it would read
ForwardSpeed (m/s).
[Tooltip("...")]¶
Hover-help text that appears on the field or button after a short delay.
Numeric ranges and validation¶
[Slider(min, max)]¶
Shows the field as a number box with a filled bar that marks where the value sits
between min and max. Dragging stops at the ends of the range. Click or double-click
to type a value; typed values are clamped to the range.
[Slider] works on int, float, double, Vector2, Vector3 and Vector4 fields.
A float or double slider drags in steps of 0.001, and an int slider in whole
numbers. Other numeric types get a plain number box clamped to the range.
Sliders on vector fields
On vector fields, each axis drags in whole units. Hold Shift while dragging for steps of 0.1, or type the value.
[ClampValue(min, max)], [Min(v)], [Max(v)]¶
These set a range without the bar: the field stays a plain number box, and both dragged
and typed values are clamped. [ClampValue] sets both bounds. [Min] and [Max] each
set one bound and combine with each other.
When a field has more than one of these, [Min] and [Max] take precedence over
[Slider], and [Slider] takes precedence over [ClampValue], whatever order they are
written in.
Widget replacement¶
[ToggleButton("On", "Off")]¶
Replaces the default checkbox on a bool field with a full-width button. The button shows
the first label while the value is true and the second while it is false, and a click
flips the value. Without arguments the labels are Enabled and Disabled. The
button's colours are fixed.
[Dropdown("A", "B", "C")]¶
Shows an int field as a drop-down list. The stored value is the index of the selected
item, starting at 0.
[Bitmask("Read", "Write", "Exec")]¶
Shows an int field as a drop-down of checkboxes. The first label is bit 0, the second
bit 1, and so on. The closed list shows the set labels separated by commas, or
(none).
[Multiline(rows: 4)]¶
Shows a string field as a multi-line text box, 4 rows tall unless you pass another
number.
[ColorPreview]¶
Shows a Vector3 (RGB) or Vector4 (RGBA) field as a colour field with a swatch. Click
the swatch to open a colour picker.
Two options change the field:
| Option | Default | Effect |
|---|---|---|
HDR |
false |
Shows the components as decimals and allows values above 1. |
Alpha |
true |
On a Vector4 field, false hides the alpha component. |
[ColorPreview(HDR = true, Alpha = false)]
public Vector4 Glow = new Vector4(4.0f, 2.0f, 1.0f, 1.0f);
Conditional display¶
The referenced field must be a bool. Both attributes accept Invert = true to flip
the condition.
[EditCondition("OtherField")]¶
The field is greyed out and cannot be edited while 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 while OtherField is true.
Visibility and access¶
Hidden fields are still saved with the scene.
[ReadOnly]¶
Greys out the field. The value still appears but cannot be edited.
[HideFromEditor] and [ShowInEditor("Label")]¶
[HideFromEditor] hides a public field. [ShowInEditor] shows a non-public field under
the label you pass. Add IsReadOnly = true to show it greyed out.
[HideFromEditor]
public float InternalState = 0.0f;
[ShowInEditor("Cached speed", IsReadOnly = true)]
private float m_CachedSpeed = 0.0f;
[ShowInEditor] only works on fields of the supported types. On a
property, or on a field of another type such as a component, it has no effect.
Action buttons¶
[Button("Label")]¶
Shows a method as a full-width button. Buttons appear below all fields, after a
separator, in declaration order. Without a label the button shows the method name, and
[Tooltip] and [DisplayName] work on button methods too.
[Button("Reset position")]
public void ResetPosition()
{
Translation = Vector3.Zero;
RotationQuat = Quaternion.Identity;
}
A button runs its method only while the scene is playing, and it is greyed out in Edit
mode. Setting RuntimeOnly = false makes the button clickable in Edit mode, but in
2026.3 clicking it there does not run the method.
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;
This field appears in a Locomotion section, labelled ForwardSpeed (m/s), as a slider from 0 to 1.5 with a tooltip.
The full set¶
Every attribute is documented individually in the Editor Attributes reference.
Attributes without an effect in 2026.3
[DisplayPriority], [NoClear] and [AllowedAssetTypes] compile, but they do not
change the Inspector in 2026.3. Fields always appear in declaration order, and asset
fields are neither filtered by type nor protected from being cleared.
Where to go next¶
- Editing Values: number boxes, expressions, vector and colour fields.
- Entity Lifecycle: when the script's callbacks run.
- Working with Components: the components a script can read and change.