Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Feedback Suggestion: Angular-style additions to auto-manage bindings - making the UI data-driven?

Discussion in 'UI Toolkit' started by herra_lehtiniemi, Jun 1, 2021.

  1. herra_lehtiniemi

    herra_lehtiniemi

    Joined:
    Feb 12, 2017
    Posts:
    133
    I've been working on a complicated UI with UI toolkit and the query-approach and individual binding of each element starts to get really complicated. I wish there was some ease from Angular-like style via some helper-API that would reduce boilderplate-code.

    Background info:
    1) My UI is built on changing data (array of classes), so I can't use the binding_path, but have to search for individual properties inside the classes each time the data changes.

    2) All the bindings and unbindings I have to do each time for example a tab changes on the UI becomes quite cumbersome after the application gets bigger.

    Suggestions:
    I'd like to see a high-level API (package) on top of the current implementation. Something that could make something like this possible (ideas from Angular):

    Code (CSharp):
    1. <engine:Button text="Current state" [value]="SettingsManager.instance.isButtonPressed" />
    or

    Code (CSharp):
    1. <engine:Label text="Conditional label" [showIf]="SettingsManager.instance.shouldShowLabel" />
    or even something like this:

    Code (CSharp):
    1. <engine:TextField [value]="SettingsManager.instance.myArray[0]?.textValue" />
    In the case above - if null is returned, it would just not bind and when the appropriate content appears, it would automatically bind.

    Perhaps these ideas are totally against the technical underlying base you have, but I'm mostly after the EASE of achieving these things. The solutions could be something totally different that fits the current implementation better. I just wish it would take less code and worrying to achieve this kinds of things.

    Currently the system is build on traditional callbacks and queries. I would wish there was some addition of variable state watches, that one could use. I would much rather bind the UI to my data than binding the data to my UI.

    I really wish binding to data would have some idiotproof top layer with zero boilerplate-code. Currently it takes so much time to make sure bindings and unbindings work. And conditionally displaying items has to be written in a method instead of just directly telling the component when to show and when not.

    So basically: to more easily bind the UI to my data and automatically reflect changes in the data.
     
    Last edited: Jun 1, 2021
  2. herra_lehtiniemi

    herra_lehtiniemi

    Joined:
    Feb 12, 2017
    Posts:
    133
    If someone has suggestions on how to code UI Toolkit more data-driven, I'd greatly appreciate any help!
     
    YuuHao likes this.