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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Bug when creating a listview programmatically, the binding of the first Element will always fail

Discussion in 'UI Toolkit' started by elesssar, Sep 4, 2022.

  1. elesssar

    elesssar

    Joined:
    Apr 17, 2019
    Posts:
    2
    I'm using the official bind-to-list example, and try to create the game_switch.uxml programmatically
    upload_2022-9-5_0-59-6.png
    The binding of the Toggle fails, and binding of TextField succeeds. it looks like
    upload_2022-9-5_1-0-49.png
    Then I moved the toggle code after the textfield code
    var box = new Box();
    box.style.flexDirection = FlexDirection.Row;
    var tf = new TextField();
    tf.style.flexGrow = 1;
    tf.bindingPath = "name";
    box.Add(tf);

    var toggle = new Toggle();
    toggle.bindingPath = "enabled";
    box.Add(toggle);
    return box;

    This time, the binding of TextField fails and Toggle succeeds.
    upload_2022-9-5_1-4-51.png
     

    Attached Files:

  2. logan_jarrett

    logan_jarrett

    Joined:
    Apr 29, 2022
    Posts:
    6
    I'm nowhere near familiar enough with this (poorly-documented-mess) yet to be of help, but are there any console errors/warnings being logged?
     
  3. elesssar

    elesssar

    Joined:
    Apr 17, 2019
    Posts:
    2
    No. No errors/warnings. It's just a bug. Easily reproduced