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

Feature Request List view add index to makeitem delegate

Discussion in 'UI Toolkit' started by Gogzy, Mar 14, 2023.

  1. Gogzy

    Gogzy

    Joined:
    Sep 17, 2021
    Posts:
    6
    While trying to recreate an editor window I made back when UI toolkit wasnt a thing yet, I was met with a problem really hard to overcome. With ReorderableList it was very easy to populate the view with different looking entries, as while creating/drawing an element it was possible to access index of an item being drawn. Now trying to do the same with a ListView it seems impossible to add different visual element depending on what index is being drawn, the only information we get about it is while binding, which makes it possible to alter some internal state of visual element, changing the way it is drawn, but still, it would be much easier to be able to add different visual element, and not the same with alterable state.
     
  2. SimonDufour

    SimonDufour

    Unity Technologies

    Joined:
    Jun 30, 2020
    Posts:
    529
    Items of the list view are reused and are not tied to a specific index. We essentially create a pool of them. Then they get bound to the indices they will display only later. If something is index specific, it is necessary to be in the bind/unbind.

    You can put all the logic inside the bind if needed, and let the makeItem return an empty visual element.
     
    Gogzy likes this.
  3. Gogzy

    Gogzy

    Joined:
    Sep 17, 2021
    Posts:
    6
    Yeah I understand and I think pooling is a great thing, but having option to use less performant behaviour, but more flexible I guess, would come in handy, especialy when extending editor window. Its just a thought tho, nothing that we couldnt live without ofc
     
  4. xuliyou

    xuliyou

    Joined:
    Dec 16, 2021
    Posts:
    1
    the bindingPath is conflict with manual bindItem function. I want take the convenience of bindingPath, but also want to have bindItem to help me to process extra content like A label in ListItemView to show the index. How can I achieve this?