UxmlAttributeField
Read time 1 minuteLast updated a month ago
A is an Editor-only control that displays a serialized UXML attribute property in the Inspector with override indicators and binding affordances.
UxmlAttributeFieldUse when building custom property drawers that inherit from to maintain visual consistency with the auto-generated Inspector UI.
UxmlAttributeFieldUxmlSerializedDataPropertyDrawer
A UxmlAttributeField in the Inspector showing a label and a value with override affordance
Create a UxmlAttributeField
You can create a in C# or UXML.
UxmlAttributeFieldCreate with C#
To create a in C# and bind it to a :
UxmlAttributeFieldSerializedPropertyusing Unity.UIToolkit.Editor;using UnityEditor;using UnityEngine.UIElements;// Inside a UxmlSerializedDataPropertyDrawer override:protected override void CreateChildPropertiesGUI(VisualElement container, SerializedProperty property){ var colorProperty = property.FindPropertyRelative("color"); if (colorProperty != null) { var field = new UxmlAttributeField(colorProperty); // The label defaults to the display name of the serialized field. // Set label explicitly to override it. field.label = "Button Color"; container.Add(field); }}
Create with UXML
To create a in UXML, use the attribute to specify which property to display:
UxmlAttributeFieldbinding-path<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uitke="Unity.UIToolkit.Editor"> <uitke:UxmlAttributeField binding-path="color" label="Button Color" /></ui:UXML>
C# base class and namespace
C# class:
UxmlAttributeFieldNamespace:
Unity.UIToolkit.EditorBase class:
VisualElementMember UXML attributes
This element has the following member attributes:
Name | Type | Description |
|---|---|---|
| | The label displayed next to the field. When not set, the label is derived from the bound property's display name. |
| | The path of the serialized property to bind and display. |
Inherited UXML attributes
This element inherits UXML attributes from .
VisualElementUSS classes
C# property | USS selector | Description |
|---|---|---|
| | USS class name applied to every |
You can also use the Matching Selectors section in the Inspector or the UI Toolkit Debugger to see which USS selectors affect the components of the at every level of its hierarchy.
VisualElement