Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question UI Toolkit List View with Horizontal Layout

Discussion in 'UI Toolkit' started by jGate99, Aug 25, 2022.

  1. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,935
    Hi there

    Current implementation is hard coded with vertical layout , It'd be really great if you can provide a ListView with horizontal layout.

    Regards
     
    MaskedMouse and dsfgddsfgdsgd like this.
  2. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,231
    It's something that is indeed in our plan. It just hasn't been prioritized yet. Main reason is that horizontal lists tend to not be as large as vertical lists and therefore benefit less from the virtualization that ListView provides. If you can provide some details about your use case for a virtualized horizontal listview, that would help us prioritize this feature.
     
    jGate99 likes this.
  3. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,649
    Maybe something like this?

     
    karl_jones, jGate99 and MaskedMouse like this.
  4. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,231
    Right, but is that going to be a list of 1000s of options? Virtualization that ListView provides is only beneficial for large numbers of items. For fewer items, a ScrollView tends to be enough, and ScrollView does have a horizontal mode.
     
  5. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,935
    Yes, an example like @superpig
    or any landscape game with 100 levels appearing in horizontal list is a must

    You already solved it for vertical so I assume that supporting horizontally shouldnt be that much a burden

    Regards
     
  6. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,649
    Yeah I don't see why the use cases that exist for a vertical list wouldn't also exist for a horizontal list. It might be less common but I think that's just because most people don't think to do it. (Or maybe because UI frameworks lack support for it :))
     
    jGate99 likes this.
  7. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,935
    @uDamian
    What about 100s levels list appearing horizontally on a landscape game?
     
  8. oscarAbraham

    oscarAbraham

    Joined:
    Jan 7, 2013
    Posts:
    431
    I don't know for sure why horizontal lists are less common. I know horizontal scrolling it's been called bad(tm) in UX circles for a long time. There's a Nilsen Norman Group study from 2005 that already said so.

    One reason could be that the traditional desktop interface, at least for windows, is not very friendly for horizontal scrolling. Traditional mouses don't have an easy way for horizontal scrolling. Another reason could be that most traditional writing systems tend to be horizontal, so it's easier to accumulate text lines vertically.

    That said, in recent years, people are finding more and more uses for long horizontal lists. The best example I can think of now is streaming services: The common usage pattern for them is that users scroll vertically to see more categories, and they scroll horizontally to see more content in a single category. I can imagine replicating this pattern for an inventory: players scroll vertically to see more categories (potions, weapons, armors), and they scroll horizontally to see all the items they have accumulated in a single category.
     
  9. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,231
    As I said, vertical virtualized ListView is in our plans. I just wanted to give a bit of justification for the choice in priorities (to not implement this yet) as well as provide potential workarounds while you wait.

    I think this little part is key:
    It's less common. And since UI Toolkit is not exactly worldly famous just yet, I don't think the lack of support is what drives overall less usage. If it was truly as desirable as vertical scrolling, users would just do it, regardless of UI framework support. It's not crazy hard to roll a custom version.
     
  10. Timboc

    Timboc

    Joined:
    Jun 22, 2015
    Posts:
    238
    I would challenge you to attempt this without internal access.
     
    spakment likes this.
  11. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,231
    It was a long time ago, but I implemented the original ListView in Unity. Internal access was not helpful because I just used regular public UITK APIs. It's only now, if you want to base yourself on top of ListView that you would need internal access. If you implement a new control from scratch that fits exactly your use case, it's not as bad and you don't need internals. The reason ListView is as complex as it is, is because it has to handle a lot of special cases (even if it is bound just the vertical axis) - like supporting non-uniform line heights.

    But don't get me wrong, I don't mean to use the excuse of "you can built it yourself" to never make a proper official version of a horizontal ListView. I'm just trying to help both with: understanding why we don't have it yet, and providing some indication that a custom approach (if you really need one now) is not out of scope for most small teams.
     
  12. Timboc

    Timboc

    Joined:
    Jun 22, 2015
    Posts:
    238
    As always, really appreciate your reply @uDamian. We are indeed a small team and creating our own version is, as you say, not out of scope.

    It is, however, incredibly hard to evaluate. My concern is that a first pass may come easy, followed by months of uncovering edge-cases. As it happens we need pretty much the full suite of options - Drag & Drop, multi-select, Desktop & mobile support, vertical & horizontal layouts, nested layouts etc.

    I'm also concerned about consistency (do we replace all ListViews in use, how do we spot a subtle change to the default runtime styles etc), missing out on accessibility features or improvements that get added over time, maintaining compatibility with our existing uxmls & c# (and catching incompatibilities).

    To make things worse we also have a release blocking bug for scroll views (https://issuetracker.unity3d.com/is...resets-when-sliders-are-scrolled-in-play-mode). Using already non-preferred Unity beta versions due to rendering issues (2022.2..b) but with no eta on backport we're about to create our own ScrollView.

    Thus, I fear, begins a slippery slope of recreating most of the UITK components that you and the team have worked hard to create and improve.

    We have actually already created our own dropdown & grid-view components but the difference here is that we were able to build on what was there, e.g. wrapping a collection of ListViews.

    As a small team it's incredibly frustrating that there's no way to keep the door open to doing small tweaks or bug fixes. With the code as a package (internalsVisibleTo) or even just some non-internal elements, we could bash our own version together that didn't completely do away with ListViewDragger, ReusableCollectionItems, CollectionVirtualizationController, SerializedVirtualizationData etc. I would strongly prefer not to rewrite all of our own versions of all of these when, on the whole, it's 98% there in terms of what we need.

    Any suggestions or advice wrt an approach that might suit us is much appreciated and as always, many thanks for your time.

    ----
    For some context (and to show we're making pretty heavy use of UITK), I've highlighted how we would like to use a horizontal ListView (using a ScrollView for now) and where we're using a gridview/mult-column-list-view (it expands to become scrollable). Fwiw we're also using multiple UI Documents and a complex render setup too.
    upload_2022-9-13_10-39-43.png upload_2022-9-13_10-41-34.png
     
  13. yasmin90

    yasmin90

    Joined:
    Sep 23, 2015
    Posts:
    1
    horizontal lists are very common in mobile
     
    spakment likes this.
  14. spakment

    spakment

    Joined:
    Dec 19, 2017
    Posts:
    96
  15. BSimonSweet

    BSimonSweet

    Joined:
    Aug 17, 2022
    Posts:
    67
    Any news on Horizontal ListView ? I need that, and I really don't want to make a custom implementation to support basic feature. And what about Grid ListView (just popped in my head :) )
     
  16. Guedez

    Guedez

    Joined:
    Jun 1, 2012
    Posts:
    827
    If you need it NOW, you can probably make a vertical list where all items on it are flipped -90º and then flip the list 90º
    You need to use C# to rotate visual elements last I checked, but it should work.
     
  17. LittleDreamerGames

    LittleDreamerGames

    Joined:
    Apr 9, 2017
    Posts:
    72
    I assume then the scroll bar would be above the list (scroll bar on right would be above if the list is rotated CCW), which might not be preferable.

    I'm here looking for a horizontal ListView too. My list is quite small, though, so I guess I'll be using ScrollView. The downside is that I don't want anything to draw outside the view at all. I guess in the future, if the list does start to get large, I will upgrade to the Horizontal ListView whenever it comes out. Hopefully in 2022 since that's what I'm currently on.
     
  18. liu1067082341

    liu1067082341

    Joined:
    Nov 16, 2019
    Posts:
    8
    Is this really not addressed 1 year later?
     
  19. C-UITools

    C-UITools

    Unity Technologies

    Joined:
    Jun 23, 2021
    Posts:
    28
    Hi @liu1067082341, we have worked on a quite a number of improvements for ListView in our most recent versions, but we have yet to tackle a truly horizontal listview. Can you give us details about your use case? perhaps we could help you come up with a workaround. :)
     
  20. berber_hunter

    berber_hunter

    Joined:
    Apr 30, 2021
    Posts:
    14
    Everything you would use a vertical one but horizontally. Including dynamic width, pooling, etc.
     
  21. liu1067082341

    liu1067082341

    Joined:
    Nov 16, 2019
    Posts:
    8
    thanks you for you help, i will use the vertical mode