Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Binding auto properties with a binding path

Discussion in 'UI Toolkit' started by Afropenguinn, Nov 22, 2021.

  1. Afropenguinn

    Afropenguinn

    Joined:
    May 15, 2013
    Posts:
    305
    So I know this is possible in code by getting the serialized property with the name "<VariableName>k__backingfield" and binding it in code, but is it possible to do so with a binding path? You can't type '<' or '>' into the binding path field.
     
  2. uMathieu

    uMathieu

    Unity Technologies

    Joined:
    Jun 6, 2017
    Posts:
    384
    If that works in code, you should be able to explicitly escape the value straight into the uxml. Can you try with "&lt;VariableName&gt;k__backingfield"?

    If it doesn't please report a bug using Help->Report a bug, we'll address it.
     
  3. Afropenguinn

    Afropenguinn

    Joined:
    May 15, 2013
    Posts:
    305
    It does work, but you have to edit the uxml directly, as in UI Builder you can't type anything into the binding path that isn't a letter, number, dash, underscore, or period.

    On the other hand, any thoughts on having official support for auto properties with serialized backing fields in UI Builder? They are supported in the inspector as of 2020. So you could just use "VariableName" instead?
     
    Last edited: Nov 22, 2021
  4. uMathieu

    uMathieu

    Unity Technologies

    Joined:
    Jun 6, 2017
    Posts:
    384
    Clearly an oversight, can you fill a bug regarding the UI Builder support for this?