Search Unity

Binding to the wrong input field

Discussion in 'UI Toolkit' started by fxlange, Nov 15, 2019.

  1. fxlange

    fxlange

    Joined:
    Dec 20, 2016
    Posts:
    45
    Hi,

    big fan of UIElements and UIBuilder :)

    Just wanted to leave this here for anyone running into the same issue:

    Spent a fair amount of time trying to debug this error, which started showing up when I tried to bind nested objects / sub properties.

    Assertion failed on expression: 'm_SerializedObject->m_SerializedObjectVersion == m_SerializedObjectVersion'


    Turned out that it had nothing to do with binding sub properties ...
    I just made the mistake to use a `TextField` for a float property (in my subclass). Switching to a `FloatField` fixed the issue but I couldn't tell from the error message.

    Best,
    Felix
     
  2. AlexandreT-unity

    AlexandreT-unity

    Unity Technologies

    Joined:
    Feb 1, 2018
    Posts:
    377
    Hi fxlange,

    Could you submit a bug report with a basic example? This error is not user-friendly at all and should probably be fixed.

    Thanks
     
  3. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,231
    I recommend trying the
    PropertyField
    element. It will generate the correct type of field (ie.
    TextField
    for
    string
    ,
    IntegerField
    for
    int
    ) when bound.

    That said, we do have specific errors when you have mix-match object field types with UI element field types. That error was caused by something else. If you have a repro case (like, switching back to using a TextField), it would be useful for us if you submitted that as a bug using the Bug Reporter in Unity.
     
    oleg_v likes this.