UxmlAttributeFieldDecorator
An Editor-only container that adds override indicators, binding affordances, and a context menu to any IBindable field.
読み終わるまでの所要時間 2 分最終更新 10日前
A is an Editor-only container that wraps any field and adds the visual affordances required for editing UXML attributes: an override indicator bar, binding state indicators, and a context menu with override and binding actions.
UxmlAttributeFieldDecoratorIBindableUse when you want to use a standard field type such as or inside a custom , but still want the field to participate in the override and binding system.
UxmlAttributeFieldDecoratorTextFieldIntegerFieldUxmlSerializedDataPropertyDrawerVisual states
The decorator changes its appearance to reflect the current state of the attribute it wraps.

UxmlAttributeFieldDecorator in four states: default, override, data binding resolved, and data binding unresolved
State | Visual indicator |
|---|---|
| Default | No indicator. The field shows the inherited or default attribute value. |
| Override | A colored bar appears on the left edge, indicating the value is set inline or as a template override. |
| Data binding resolved | A binding indicator replaces the override bar, showing the attribute is driven by a successfully resolved data binding. |
| Data binding unresolved | A binding indicator is shown in a distinct style, indicating the data binding could not be resolved. |
Right-clicking the decorator opens a context menu with actions appropriate to the current state.

The UxmlAttributeFieldDecorator context menu showing Add Binding, Unset, and Unset all options
Menu item | When available | Description |
|---|---|---|
| Add Binding | No binding | Opens the binding editor to create a data binding for this attribute. |
| Edit Binding | Binding present | Opens the binding editor to modify the existing binding. |
| Remove Binding | Binding present | Removes the data binding from this attribute. |
| Unset | Value overridden | Resets this attribute to its default value. |
| Unset all | Any override present | Resets all overridden attributes on this element to their default values. |
Create a UxmlAttributeFieldDecorator
You can create a in C# or UXML. It can contain multiple child elements, but only its first direct child is bound. The decorator automatically detects that child's binding path when it binds to a .
UxmlAttributeFieldDecoratorIBindableSerializedPropertyCreate with C#
using Unity.UIToolkit.Editor;using UnityEditor;using UnityEngine.UIElements;// Inside a UxmlSerializedDataPropertyDrawer override:protected override void CreateChildPropertyGUI(VisualElement container, SerializedProperty property, SerializedProperty childProperty){ var decorator = new UxmlAttributeFieldDecorator(); var textField = new TextField(childProperty.displayName) { bindingPath = childProperty.propertyPath }; decorator.Add(textField); container.Add(decorator);}
Create with UXML
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uitke="Unity.UIToolkit.Editor"> <uitke:UxmlAttributeFieldDecorator> <ui:TextField binding-path="label" label="Label" /> </uitke:UxmlAttributeFieldDecorator></ui:UXML>
C# base class and namespace
C# class:
UxmlAttributeFieldDecoratorNamespace:
Unity.UIToolkit.EditorBase class:
VisualElementMember UXML attributes
This element has no member UXML attributes of its own. Add any child element to wrap it with override and binding affordances.
IBindableInherited UXML attributes
This element inherits UXML attributes from .
VisualElementUSS classes
C# property | USS selector | Description |
|---|---|---|
| | USS class name applied to every |
| - | | USS class applied to the inner content container that holds the wrapped field. |
| - | | USS class applied to the affordance element that displays override and binding indicators. |
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