docs.unity3d.com
    Show / Hide Table of Contents

    Class BindingExtensions

    Provides VisualElement extension methods that implement data binding between INotivyValueChanged fields and SerializedObjects.

    Inheritance
    Object
    BindingExtensions
    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.

    In This Article
    • Fields
      • prefabOverrideUssClassName
    • Methods
      • Bind(VisualElement, SerializedObject)
      • BindProperty(IBindable, SerializedObject)
      • BindProperty(IBindable, SerializedProperty)
      • TrackPropertyValue(VisualElement, SerializedProperty, Action<SerializedProperty>)
      • Unbind(VisualElement)
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023