Search Unity

BaseVerticalCollectionView, need more flexibility

Discussion in 'UI Toolkit' started by Cripplette, Jul 27, 2021.

  1. Cripplette

    Cripplette

    Joined:
    Sep 18, 2012
    Posts:
    66
    Hi,

    I use intensively UnityUI for infinite lists that have the following features :
    • Dynamic items height
    • Custom UI Item representation depending on the data
    I would like to migrate to UI Toolkit for performances & layout functionnalities, but I need both of those features in order to be able to migrate.

    Would it be possible to add the index of the data in << makeItem >> of ListView, in order to be able to provide different kind of VisualElement depending on the data.

    Another request is for the dynamic items height is the functionality to provide it by code. Can you please make the function that calculates the height of the item at a given index VIRTUAL please ?

    In a more general way, can you please make your functions virtuals, because I would like to be able to override everything and add my own stuff please ?
     
  2. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    780
    Which version of UI Toolkit are you using? Dynamic height support was in 2021.2 beta.

    Note that this will come at a performance penalty. Using a fixed height allows the ListView to easily virtualize elements, while a dynamic height more work is needed to estimate item size and observe the actual size as elements become visible.

    In any case, it is unlikely that we will provide an index parameter to makeItem, since items are recycled no matter the index of the item they were first created for.
    You can use the bindItem callback, which takes the index, to reset the element and populate it according to the data. However this could negatively impact performance if you are doing big hierarchy operations everytime bindItem is called.