Forum rules - please read before posting.

Inventory scrolling - without buttons

Hi,
I'm having trouble figuring out the best way to implement scrolling inventory using keyboard or a controller, without having buttons on either end.
I played around with unity's built in ui scroll stuff but it's total dogsh#t when it comes to performance and doesn't even support scrolling stuff when you move below the last cell in the viewport!
A bunch of dudes posted various fixes for it but I've had no real luck with it, and am a little worried that anything I cobble together might cause problems with the way the AC inventory system integrates with unity ui.

Essentially what I'm after is a grid with six visible slots for items, and six more hidden below. If you scroll to the bottom with the assigned down key, or a controller stick and then move down one more spot, it will automatically move the grids up and display a new row at the bottom. This will keep going until you reach the last row of boxes.
If you then scroll up, the same would happen in reverse.
Idea is that you have a limit of 12 item slots (since my game has survival horror elements such as limited carrying capacity, health and ammo for combat, and item combination) but at any given time, there're only 6 slots visible on the inventory screen.

Would it be possible to use the functionality built into the scroll buttons in the unity ui inventory tutorial, but map it to either a keypress/stick movement when at the bottom/top?

Other option I thought of was using an invisible button at the bottom that does that same job when you move onto it in unity's built in ui navigation?

Comments

  • Would it be possible to use the functionality built into the scroll buttons in the unity ui inventory tutorial, but map it to either a keypress/stick movement when at the bottom/top?

    You can "shift" multi-slot elements through script - just call its Shift function:

    MenuElement elementToShift = PlayerMenus.GetElementWithName ("MyMenu", "MyInventoryBox");
    elementToShift.Shift (AC_ShiftInventory.ShiftNext, 1);
    

    Other option I thought of was using an invisible button at the bottom that does that same job when you move onto it in unity's built in ui navigation?

    That'd be viable, too. You could hide your menu-linked Shift buttons from view, and then have a script both invoke the button, and select the previous UI element, when selected.

    am a little worried that anything I cobble together might cause problems with the way the AC inventory system integrates with unity ui.

    This, too, should be OK - so long as AC thought of all slots as being displayed at once. If AC considers all slots are visible, it won't control their respective visibility states, so you should be able to rely on hiding them inside a scroll element.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.