Unity-specific C# attributes
Understand how to use Unity-specific C# attributes to change how the Unity Editor and runtime treat your code.
Read time 1 minuteLast updated 3 days ago
Attributes in C# are metadata markers that can be placed above a class, field, or method declaration to indicate special behavior.
There are many attributes defined in the .NET libraries and Unity also provides many Unity-specific attributes. For example, you can add the attribute above a field declaration to prevent the window from showing the field, even if it's public. Place attributes in square brackets above the declaration as follows:
HideInInspectorInspector
?
[HideInInspector]public float strength;
For the full list of attributes, refer to the list under UnityEngine > Attributes in the Scripting API reference, which begins with .
UnityEngineAddComponentMenuFor the full list of attributes, refer to the list under UnityEditor > Attributes in the Scripting API reference, which begins with .
UnityEditorAssetPostprocessorStaticVariableIgnoreAttributeAdditional resources
- Attributes (Unity Learn)
- Inspecting scripts
- Script serialization rules