Search Unity

Bug UI builder wiping out content of multiple XML files

Discussion in 'UI Toolkit' started by useraccount1, Sep 2, 2020.

  1. useraccount1

    useraccount1

    Joined:
    Mar 31, 2018
    Posts:
    275
    I wanted to learn how to use list view and scroll view and noticed that by (possibly unwanted) set of moves you can wipe out content of XML files.

    bug report: Case 1274846

    I have recorded short video to explain everything:


    1. Open everything in the editor, so an ItemInfo.uxml and USS_Base.uss and USS_Buttons.uss
    2. Create ListView
    3. Create VisualElement by dragging it, at the same time you have to drag it to something like unity-content-container. The bug can be reproduced when you move It to others elements of ListView
    4. Save
    5. VisualElement will be pushed to the top of the hierarchy, NOTE: You can replicate everything with ScrollView to this point. However, It ends here. I think this should be considered as another bug.
    6. Move VisualElement under ListView again
    7. Save and save
    8. XML files are gone.
     
  2. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,231
    This is all actually by design. We've landed a "fix" in recent versions of UI Toolkit package that will prevent you from adding children to ListView in the first place to avoid this confusion and subsequent problems within the UI Builder (which are all legitimate problems), but the fact the ListView clears its children is expected.

    The reason is that ListView is a _virtual_ container of elements, designed for really large datasets, where each UI element is recycled as you scroll (instead of creating a whole bunch of UI elements that you will never actually see). Therefore, it expects full control over its child elements and will clear them often.

    For manual content that you want scrollable, use a ScrollView instead.

    Here's a lot more info on ListView:
    https://forum.unity.com/threads/lis...anything-in-customeditor.952706/#post-6228084
     
    useraccount1 likes this.