Unity attributes: a practical guide
↑Unity 6
At a glance
Section titled “At a glance”C# attributes are metadata written in square brackets, such as [SerializeField]. Unity reads many of them to decide how to show fields, register components, initialize code or compile jobs. They do not replace validation, clear dependencies or performance measurements.
Choose a category
Section titled “Choose a category”Inspector and serializationFields, visibility, rename migrations and input controls.
Components and executionDependencies, edit-time callbacks and execution order.
Editor and method hooksContext menus, menu commands and initialization.
Jobs and performanceBurst, NativeArray, memory lifetime and safety risks.
Compare similar attributesLearn which attribute fits your situation and why.
How to use this reference
Section titled “How to use this reference”- Decide whether you need to affect saved data, the Inspector UI, a component, the Editor, or a job.
- Check the attribute’s target, namespace and optional package requirements.
- Copy an example and test it with a real scene or prefab.
- Also test a player build when using Editor APIs or conditional compilation.
Things worth remembering
Section titled “Things worth remembering”A frequent source of confusion is the difference between an attribute affecting the Editor and an actual runtime guarantee. A [Range] slider does not validate network input, and a hidden field can still be serialized.
The five guides are based on Unity’s official scripting API documentation, with original explanations and practical examples.
