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.
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.
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.
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:
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 ListViewdragging area to make scrolling works as expected, which is by dragging any items or content currently displayed in the list?
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?
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.
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.