Search Unity

Question Officially recommended workflow to set up a "list of items" in Editor window?

Discussion in 'UI Toolkit' started by Fritsl, Aug 19, 2020.

  1. Fritsl

    Fritsl

    Joined:
    Mar 10, 2013
    Posts:
    211
    1 C#
    1 UXML

    Together these should produce an Editor window that has a "Scrollable List of items".

    "List" can technically be a "ScrollView, ListView or..?". "Items" can be buttons, labels, IntFields. Not just property fields (because then why even use these tools) but at least VisualElements such as Labels ;) Data source in C# can be anything, just a <List> of Strings.

    What would be "a right way using UI Builder in the UI Tools framework", to produce such a UI "list"?

    Trying to use the "Official right ways":
    • UXML (produced by UI Builder) should create all objects (so UI Builder can be used to design an "Item" to be cloned, no codeporn inline in C#, clear separate functions
    • C# should create "items" on "list" from C# held Array or C# List for example <String>
    • C# should offer delete "item" on "list" and refresh "the list" (but not the entire UI, how is dynamic update handled in the Retained Mode system?)
    • C# should should offer easy reference to what happens if user press one of the "items" on the "list"
    Thank you very, very much out there :)
    --------------------------------
    Disclaimer: I tried to start another tread on this topic, but it's drowning in "alternative suggestions", so I have realized I have to ask with focus on this key point that I before took for granted:
    Unity writes: "Although you can build interfaces directly in C# files, Unity recommends using UXML documents in most cases." -> Please do not discuss that, it is my goal to learn this ;)
     
  2. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,231