Field Attributes
Serialization, field labels and Inspector editing in Unity.
Reference baseline: Unity 6.0 API; Burst entries use the Burst 1.8 manual. Namespaces and placement are requirements, not claims about the first supported Unity version.
Attribute fragments belong on the declaration described by their requirements; alternatives are shown separately.
SerializeField
Section titled “SerializeField”Serialize a private field so it appears in the Inspector.
[SerializeField]Requirements: UnityEngine; serializable instance field.
Use for private variables you want editable without exposing as public.
A private field can stay editable without becoming part of the public API:
using UnityEngine;
public class InspectorExample : MonoBehaviour{ [SerializeField] private int serializeField;}The normal Inspector displays this supported private field and saves its value.
HideInInspector
Section titled “HideInInspector”Hide a public or serialized field from the Inspector.
[HideInInspector]Requirements: UnityEngine; serialized field.
Good for keeping data serialized but uncluttered in the Inspector.
NonSerialized
Section titled “NonSerialized”Exclude a field from Unity serialization and the normal Inspector.
[NonSerialized]Requirements: System; field target; Unity serialization rules.
The field is not saved to a scene or prefab. A public field does not remain visible in the normal Inspector merely because it is public.
FormerlySerializedAs
Section titled “FormerlySerializedAs”Remap serialized data from an old field name after renaming.
[FormerlySerializedAs("oldName")]Requirements: UnityEngine.Serialization; serialized field.
Header
Section titled “Header”Draw a bold header label above this field or group.
[Header("Title")]Requirements: UnityEngine; Inspector field.
Insert vertical space before the next field.
[Space]
// Alternative: specify the gap in pixels.[Space(12)]Requirements: UnityEngine; Inspector field.
Plain [Space] uses the default gap; use the numeric constructor to fine-tune spacing.
Tooltip
Section titled “Tooltip”Show hover-popup help text for the field label in the Inspector.
[Tooltip("Movement speed in units per second.")]Requirements: UnityEngine; Inspector field.
Draw an Inspector slider for an int or float between constant bounds. This constrains Inspector editing; it does not clamp assignments made by your runtime code.
[Range(0f, 1f)]Requirements: UnityEngine; int or float Inspector field; constant bounds.
Uses the built-in Inspector slider styling.
Set a minimum for numeric Inspector editing, without a slider. Runtime code can still assign a smaller value.
[Min(0f)]Requirements: UnityEngine; int or float Inspector field; constant minimum.
The original reference intended an upper limit without a slider, but MaxAttribute is not a documented Unity core attribute. Its behavior depends on a specific custom or package implementation.
// Requires an identified custom or package MaxAttribute implementation.[Max(100f)]Requirements: Not established as a Unity core API; custom or package implementation required.
Unity core attribute declarations
Do not paste this into a plain Unity project expecting a built-in attribute. The official Post Processing package has its own Max declaration; that is package-specific evidence, not a general Inspector guarantee.
TextArea
Section titled “TextArea”Draw a multiline string field with minimum and maximum visible line counts. These bounds control the text area height, not the maximum text length.
[TextArea(3, 6)]Requirements: UnityEngine; string Inspector field; integer line bounds.
Multiline
Section titled “Multiline”Attribute to make a string be edited with a multi-line textfield.
[Multiline]Requirements: UnityEngine; string Inspector field.
Unlike TextArea, height is fixed; good for short paragraphs.
Delayed
Section titled “Delayed”Delay committing an int, float or string Inspector edit until Enter is pressed or the field loses focus.
[Delayed]Requirements: UnityEngine; int, float or string Inspector field.
Avoids applying intermediate values while typing, useful for expensive editor updates.
SerializeReference
Section titled “SerializeReference”Serialize a managed reference to a supported serializable class, including polymorphic values behind abstract class or interface fields. The concrete object must satisfy Unity managed-reference serialization rules.
[SerializeReference]Requirements: UnityEngine; managed reference to a supported serializable class.
Not for value types or structs. This attribute alone does not promise an Inspector UI for choosing concrete implementations.
InspectorName
Section titled “InspectorName”Override the Inspector display name of an enum value. This is not a general field-label renaming attribute.
[InspectorName("Name")]Requirements: UnityEngine; enum value declaration.
ContextMenuItem
Section titled “ContextMenuItem”Add a command to a field’s Inspector context menu that invokes the named non-static method. It does not add a button beside the field.
[ContextMenuItem("Reset", "ResetValue")]Requirements: UnityEngine; field plus a named instance method.
NonReorderable
Section titled “NonReorderable”Prevent list reordering UI on a List.
[NonReorderable]Requirements: UnityEngine; array or list Inspector field.
Use when index order has semantic meaning tied to code.