Search Unity

Feature Request Bind Element‘s Properties

Discussion in 'UI Toolkit' started by sunsi12138, Sep 22, 2021.

  1. sunsi12138

    sunsi12138

    Joined:
    Apr 14, 2020
    Posts:
    23
    Hey,guys,

    I Wonder whether developer can bind the element's property to gameobject or a script's property like visiability or position?the current editor bind system seems to designed for change gameObject's property, more like one-way bind. SO whether the coming runtime binding allow the dev to updatethe visualelement's proper by bind them to other serialized property?

    of course it can be done with custom c# code,but I think that would be exciting as a native way
     
  2. griendeau_unity

    griendeau_unity

    Unity Technologies

    Joined:
    Aug 25, 2020
    Posts:
    248
    You can use the attribute `binding-path` in UXML to bind most of our controls to a property. You can also use the PropertyField for most cases. The binding two-way, you need to make sure the modified properties are applied to the serializedObject (serializedObject.ApplyModifiedProperties())

    As for the upcoming runtime support for binding, not sure I fully understand the question, but the solution would ultimately allow the same functionality on a serialized property path and would be supported in uxml.