I’m making the UI/UX for a game my development team is making, and this is the current layout of the UI for the multiplayer lobby / character select. The intended implementation/flow is this; In this screen the player chooses a character from the bottom icons, then once a character is selected they move through cosmetic options, with the center item being the currently selected one. The weapon and cosmetic options are something the player unlocks over time so the amount of items that the player can scroll through is constantly changing.
Example of cosmetic scroll below;
< [ x ] [ X ] [ x ] >
The center object is the selected object, I’d like to be able to scroll left and right with dpad or wasd/arrow keys.
My first thought when setting this up was to use Unity’s Scrollview component, but the problem I’m having with that is it doesn’t scroll when using a controller. It seems to only work when the mouse is hovering over the area and using the mouse scroll or dragging with the mouse. This game NEEDS to be useable on controller and keyboard/mouse.
Is there a way to make Unity’s Scrollview component scroll with a controller?
Is there another way I should be approaching this system?
If more info is need to help let me know!
I don’t know if I’d use a scroll view. I would probably code this up as a custom visual element that you have more explicit control over. Would need to be designed to work with an arbitrarily sized collection; ideally it just wraps around when it gets to either end of the collection.
As for dealing with input, a component can easily control this with a gamepad. For mouse-scroll input, I would register callbacks for pointer enter/exit so it can handle scroll inputs only when a pointer is inside it (or has focus maybe?). Or maybe just have it controlled with A/D for simplicity’s sake?
Honestly a UI control like that is something on my to-do list for my current project (think Monster Hunter item bar), so I’ve been thinking about this a bit.
Well, if your gamepad navigation is working correctly, you can use FocusInEvent to check if the new focused element is visible or not, if it’s not visible you can use scrollViewElm.ScrollTo(focusedElement) to scroll. We had some problems in Unity 21 LTS with scroll views, scrollTo function and navigation system, so I wrote a custom system to handle this (which is basically more stable custom system with the same functionality).
You can also write your custom scroll function if you want an eased one (like, parent.ScrollTo(child, 0.5f) to make a smooth scroll).