Search Unity

ListView requested features

Discussion in 'UI Toolkit' started by Cripple, Oct 14, 2020.

  1. Cripple

    Cripple

    Joined:
    Aug 16, 2012
    Posts:
    92
    Hi,

    We use intensively UnityUI for our application, and we have built a library with a great amount of functionnalities. We all know the limitation of UnityUI and the promises of UI-Toolkit are really tempting. We want performances and we want a real layout system !!!

    In order to be able to switch to UI-Toolkit, the most important features needed are the one for ListView :
    • Is it possible to customize the template used to represent an UIElement in the ListView ? Each element template may change according to the data to display.
    • If the feature above is possible, could the UIElement have different height ? The height would be calculated by the template provider when the element is bound (a dynamic height that could change at runtime dynamically would be the icing on the cake).
    I have looked at ListView code for UIToolkit, and it seems that all UI-Items have the same template, and the same height, but do you plan to add those features ? If not we will have to override the ListView by ourself.
     
  2. SimonDufour

    SimonDufour

    Unity Technologies

    Joined:
    Jun 30, 2020
    Posts:
    572
    Hi Cripple,

    The ListView is a special component meant for displaying large quantity of similar element. Under the hood, only the visible elements are generated and as you scroll, and the elements get reused with different data. Because it is meant for high performance, assumption are made regarding the content, like it height, to speed up the usage.

    If you want to do something with varying height that doesn't have large numbers of elements, you can simply use the ScrollVew, which will be more flexible and that would allow doing what you described. The drawback would be that the layout is calculated even on the elements not currently displayed in the view.

    While a varying height ListView would be nice, I don't think it was in the list of features we are prioritizing at the moment. I could check specifically if you want.
     
  3. Cripple

    Cripple

    Joined:
    Aug 16, 2012
    Posts:
    92
    Hello,

    Hi, we already have an infinite ListView with those features developped with UnityUI. It handles separate DataModel with a lot of Data into it, custom Template depending on the Data, and custom height when items are bound to the ListView. The implementation is based on this :https://assetstore.unity.com/packages/tools/gui/enhancedscroller-36378

    We only use Basic ScrollView when the item of our list may have items with dynamic size that can't be provided by the Template.

    That is why we will switch to UI-Toolkit only if we have the same fonctionnalities.
     
  4. benoitd_unity

    benoitd_unity

    Unity Technologies

    Joined:
    Jan 2, 2018
    Posts:
    331
    Hi, it's in our plans to provide variable height support for the ListView but it won't make it for first release.
     
    Cripple likes this.
  5. ggarciacordovi

    ggarciacordovi

    Joined:
    Nov 1, 2014
    Posts:
    6
    Hi,

    Using versions 1.0.0-preview.9 and 1.0.0-preview.12 of Unity UI Toolkit I found the following issues with the ListView on Android devices:
    1) Scrolling the list by dragging its content or its items only works when dragging the first few items (4 or 5) of the list. Is there a any way to expand the ListView dragging area to make scrolling works as expected, which is by dragging any items or content currently displayed in the list?
    2) Horizontal scrolling occurs even when no horizontal scrolling is enabled. I guess this is happening because the inner ScrollView was created using the ScrollViewMode.VerticalAndHorizontal constructor's argument when created by the ListView. Is there any way to change the ScrollViewMode of a ScrollView object after it has been created? Is there any way to ensure the ListView doens't scroll horizontally?

    Thanks.
     
  6. griendeau_unity

    griendeau_unity

    Unity Technologies

    Joined:
    Aug 25, 2020
    Posts:
    248
    Hi ggarciacordovi,

    This was fixed not so long ago and should hit the public version soon, probably in preview.13, but will also be fixed in 2021.1.
    For point 1, what probably happens in your case is that the first items do not capture the pointer (e.g. Labels), and other items do (buttons, toggles, etc.), which prevents dragging on these elements. This is now fixed and all controls should accept touch dragging.
    For point 2, this was a bug in the ScrollView implementation and will be solved in the next version.

    Stay tuned !
     
  7. ggarciacordovi

    ggarciacordovi

    Joined:
    Nov 1, 2014
    Posts:
    6
    Hi,

    Thank you for you quick response. All items in my list use the same markup or template, the first few items are not different from the rest. None of the items in my list capture the pointer. This behavior seems to be a manifestation of the existing bugs in the ListView or ScrollView.

    Thanks again,
     
  8. ggarciacordovi

    ggarciacordovi

    Joined:
    Nov 1, 2014
    Posts:
    6
    Still not fixed in preview.13...
     
  9. manuelgoellnitz

    manuelgoellnitz

    Joined:
    Feb 15, 2017
    Posts:
    397
    I think preview.13 was rushed and was mainly a hotfix. that it can work with the latest uibuilder-version.
     
  10. ggarciacordovi

    ggarciacordovi

    Joined:
    Nov 1, 2014
    Posts:
    6
    Is this already fixed in the latest version of UI Toolkit package?
     
  11. manuelgoellnitz

    manuelgoellnitz

    Joined:
    Feb 15, 2017
    Posts:
    397
    Yes it works
     
  12. ggarciacordovi

    ggarciacordovi

    Joined:
    Nov 1, 2014
    Posts:
    6
    In version preview 14?
     
  13. manuelgoellnitz

    manuelgoellnitz

    Joined:
    Feb 15, 2017
    Posts:
    397
    preview 13 is the latest ui toolkit version the package manager shows me
     
  14. ggarciacordovi

    ggarciacordovi

    Joined:
    Nov 1, 2014
    Posts:
    6
    Still doesn't work in preview 13 on mobile platforms.