Search Unity

Data Binding to Gameobject property

Discussion in 'UI Toolkit' started by chrisco_unity, May 11, 2022.

  1. chrisco_unity

    chrisco_unity

    Joined:
    Nov 15, 2018
    Posts:
    1
    Hi,

    Im struggling to figure out how to bind the data from a slider to just a simple property field in a c# script. The docs say that binding can only be done to serialized properties, and Serialized data binding only works in editor and not in run time?

    Is there a runtime equivilant of data binding? Or am I missing a finer point? Ive been through the examples, but they all seem be based on editor scripting or the inspector.

    Thanks in advance
     
    pandazaurus and LogicFlow like this.
  2. jonathanma_unity

    jonathanma_unity

    Unity Technologies

    Joined:
    Jan 7, 2019
    Posts:
    229
    This is something that we are currently working on. As of today binding only work in the editor.
     
    LogicFlow and chrisco_unity like this.
  3. adammpolak

    adammpolak

    Joined:
    Sep 9, 2018
    Posts:
    450
    @jonathanma_
    Can this work reverse?

    There is a monobehavior variable

    m_Score

    And this can be bound to a Runtime UI label?

    So as the Monobehavior variable updates, so does the label text?
     
  4. jonathanma_unity

    jonathanma_unity

    Unity Technologies

    Joined:
    Jan 7, 2019
    Posts:
    229
    As stated, currently there is no data binding solution for runtime UI but we are actively working on it.
     
    adammpolak, jGate99 and Thimo_ like this.
  5. gwelkind

    gwelkind

    Joined:
    Sep 16, 2015
    Posts:
    66
    Still no data binding?

    Are there any good 3rd party solutions?
     
  6. jonathanma_unity

    jonathanma_unity

    Unity Technologies

    Joined:
    Jan 7, 2019
    Posts:
    229
    Not yet but it's quite far in development and should come out next year.
     
  7. _geo__

    _geo__

    Joined:
    Feb 26, 2014
    Posts:
    1,341
    Hi, any update on this? Is there an ETA?
     
    JakobAnarkyLabs and Silentor666 like this.
  8. jonathanma_unity

    jonathanma_unity

    Unity Technologies

    Joined:
    Jan 7, 2019
    Posts:
    229
    Hi, ETA is Unity 2023.2.
     
  9. Nostromos

    Nostromos

    Joined:
    Nov 30, 2019
    Posts:
    22
    so did this make it into Unity 2023.2? The alpha is now available - is runtime data binding in the UI toolkit now?
    thanks!
     
    Last edited: May 6, 2023
    ThatGuyFromTheWeb likes this.
  10. theunsigned

    theunsigned

    Joined:
    Nov 15, 2018
    Posts:
    33
    Does anyone know the answer to this? I see "binding-path" in the documentation but haven't been able to test it yet am finding no help in the docs. It seems like binding is just for the editor, though there's a progress bar with a binding field...
     
  11. cpalma-unity

    cpalma-unity

    Unity Technologies

    Joined:
    Nov 30, 2020
    Posts:
    110
    Hello, the ETA for runtime data binding is still 2023.2. We should have more news about this soon :)
     
  12. theunsigned

    theunsigned

    Joined:
    Nov 15, 2018
    Posts:
    33
    Thank you so much for that information. Is there a recommended means of implementing progress bars using UI Toolkit at this time? I've used sliders and am trying to learn more about creating custom controls to implement things like current progress level, a threshold line, max amount, etc. but am a little lost on that as well as how to do simple things like change the slider handle image. I'm honestly confused by the "greying out" of the control elements and am looking forward to the advancement of UI Toolkit. UI Builder is an excellent tool for designing UI, kudos to the team.

    Maybe a more noob/intermediate-friendly series of tutorials on how to implement events/actions with this system beyond the onclickevent? Just thoughts from someone trying to teach themselves and fill in knowledge gaps.

    Thank you again

    **EDIT** I was over/under thinking this after confusing myself with too much research. You can still link a scriptableobject float value to the ProgressBar value in Monobehavior very easily. I haven't tested it with Actions/events but it's definitely not as complicated as I thought. Just ignore the binding path part for now (unless you're doing an editor script)
     
    Last edited: May 27, 2023