-
Notifications
You must be signed in to change notification settings - Fork 0
HideLabel Attribute
The [HideLabel]
attribute is a simple attribute that removes the label of a field in the Unity Inspector. The attribute is useful when the label itself doesn’t add much context or when dealing with inspector elements that benefit from a streamlined display.
Note: These examples use Unity’s
[SerializeField]
onprivate
fields to promote encapsulation. This approach can help protect internal data from unintended access by other scripts and maintain clean, organized code. For more details, see Unity’s documentation on SerializeField.
Using [HideLabel]
is straightforward. Simply apply the attribute above the field you want to display without a label.
[HideLabel]
[SerializeField]
private int valueWithoutLabel;
Let’s say you want to display a float without a label, for instance, as a transparency or scale factor where the field’s purpose is clear without an additional label.
[HideLabel]
[SerializeField]
private float transparency;
Result: In the Inspector, this field will display only the float input box without a label, making it more visually streamlined.
You can also apply [HideLabel]
to native Unity types like Color
to hide the label, useful when the color picker speaks for itself.
[HideLabel]
[SerializeField]
private Color mainColor;
Result: The Color
field will show only the color picker without the label, creating a minimalistic and user-friendly look.