Class BindingExtensions
Provides VisualElement extension methods that implement data binding between INotivyValueChanged fields and SerializedObjects.
Namespace: UnityEditor.UIElements
Syntax
public static class BindingExtensions : object
Fields
prefabOverrideUssClassName
USS class added to element when in prefab override mode.
Declaration
public static readonly string prefabOverrideUssClassName
Field Value
Type | Description |
---|---|
String |
Methods
Bind(VisualElement, SerializedObject)
Binds a SerializedObject to fields in the element hierarchy.
Declaration
public static void Bind(this VisualElement element, SerializedObject obj)
Parameters
Type | Name | Description |
---|---|---|
VisualElement | element | Root VisualElement containing IBindable fields. |
SerializedObject | obj | Data object. |
BindProperty(IBindable, SerializedObject)
Binds a property to a field and synchronizes their values. This method finds the property using the field's binding path.
Declaration
public static SerializedProperty BindProperty(this IBindable field, SerializedObject obj)
Parameters
Type | Name | Description |
---|---|---|
IBindable | field | VisualElement field editing a property. |
SerializedObject | obj | Root SerializedObject containing the bindable property. |
Returns
Type | Description |
---|---|
SerializedProperty | The serialized object that owns the bound property. |
BindProperty(IBindable, SerializedProperty)
Binds a property to a field and synchronizes their values.
Declaration
public static void BindProperty(this IBindable field, SerializedProperty property)
Parameters
Type | Name | Description |
---|---|---|
IBindable | field | VisualElement field editing a property. |
SerializedProperty | property | The SerializedProperty to bind. |
TrackPropertyValue(VisualElement, SerializedProperty, Action<SerializedProperty>)
Checks the property values for changes every frame. Executes the callback when the property value changes. If no callback is specified, a SerializedPropertyChangeEvent is sent to the target element.
Declaration
public static void TrackPropertyValue(this VisualElement element, SerializedProperty property, Action<SerializedProperty> callback = null)
Parameters
Type | Name | Description |
---|---|---|
VisualElement | element | VisualElement tracking a property. |
SerializedProperty | property | The SerializedProperty to track. |
Action<SerializedProperty> | callback | Invoked when the tracked SerializedProperty value changes. |
Unbind(VisualElement)
Disconnects all properties bound to fields in the element's hierarchy.
Declaration
public static void Unbind(this VisualElement element)
Parameters
Type | Name | Description |
---|---|---|
VisualElement | element | Root VisualElement containing IBindable fields. |