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 are updating our Terms of Service for all Unity subscription plans, effective October 13, 2022, to create a more streamlined, user-friendly set of terms. Please review them here:
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

BaseVerticalCollectionView, need more flexibility

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

  1. Cripplette


    Sep 18, 2012

    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


    Unity Technologies

    Sep 10, 2015
    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.