Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  3. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question UXML Runtime binding questions

Discussion in '2023.2 Beta' started by SebMaire, Aug 23, 2023.

  1. SebMaire

    SebMaire

    Joined:
    Feb 9, 2021
    Posts:
    12
    Hello There,

    I'm using the new runtime binding system in a project and this works really well for the moment.
    Coming from a WPF background, I have some naturally occuring questions.

    - Is there any equivalent of "ConverterParameter" when using Converters ?
    I checked the definition of DataBinding and it seems there is nothing for it.

    - Is it possible to do things like "RelativeSource" bindings allowing to bind some properties of the front together ?

    - When using WPF you can use a thing called implicit DataTemplate to allow for example Instiating different UIs based on the type of the real type of the model for example
    The syntax looks something like this

    <DataTemplate DataType="{Type1}">
    <MyWonderfulUIComponent/>
    </DataTemplate>
    <DataTemplate DataType="{Type2}">
    <AnotherOneJustAsGoodUIComponent/>
    </DataTemplate>

    This is super practial to define it on the XML side and works for instantiating different controls in a list for example.
    In unity this is achievable with a converter I think but it would be great to allow defining it in the XML.

    Thank you !
     
  2. martinpa_unity

    martinpa_unity

    Unity Technologies

    Joined:
    Oct 18, 2017
    Posts:
    484
    Hi @SebMaire!

    We do not have this feature. However, on an instance of a
    DataBinding
    , you can set binding-specific converters (through
    DataBinding.sourceToUiConverters
    and
    DataBinding.uiToSourceConverters
    ), which can use a closure.

    Yes, during the update of a
    DataBinding
    , the
    dataSourcePath
    of an element is computed by combining all
    dataSourcePath
    between the element and the resolved
    dataSource
    .

    That is not currently a feature supported by the UXML format. I would suggest to make a feature request for this.

    Hope this helps!