Hi, I'm trying to make an inventory menu that scrolls without the use of ui buttons like the default inventory. My ideal is to be able to use both the horizontal axis keys (AD / left and right arrows) as well as the mouse wheel, but for now I'm starting off with just the direct navigation for simplicity (although I'd appreciate it if someone can explain how to combine both, I read somewhere that there has to be another event system but I'm not sure how to go about that).
Okay, so using direct navigation with the default inventory forces you to still click on the ui buttons to scroll, so I created a new Unity UI menu just as simple as the default ac one, but without those buttons. I attached a script to the canvas with the following methods:
public void ShiftRight()
{
MenuElement elementToShift = PlayerMenus.GetElementWithName(menuName, elementName);
elementToShift.Shift(AC_ShiftInventory.ShiftNext, 1);
}
public void ShiftLeft()
{
MenuElement elementToShift = PlayerMenus.GetElementWithName(menuName, elementName);
elementToShift.Shift(AC_ShiftInventory.ShiftPrevious, 1);
}
And finally, I created 2 active inputs, one for each direction. The thing is the axis type is very sensitive and I don't know how to fix that, because if I choose button type it works perfectly (but given "Horizontal" is an axis, using it as a button would only work if it was 1 direction I needed). But if I choose axis type it scrolls like crazy and I'd have to tap the buttons very lightly for it to only scroll once per tap.
Finally, if I manage to make that work, I now have the problem that it's scrolling every time I tap A or D, when it should only do that once it reaches the end or beginning of the slots in the inventory. How should I tackle that?
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
If it works better with Button, stick to that. You can still separate to Right/Left inputs that are mapped to the same keys as Horizontal.
Alternatively, if you read the input directly through script, you can have the buttons be prevented from being invoked again until the input is read as zero.
You're talking about the selected item scroll?
You can check that the current "hover" item is the first in the InventoryBox before shifting left, and that it's the last before shifting right, before invoking the Buttons.
Something like:
You're totally right, I forgot I could use check input in the actionlist to separate the axis direction afterwards. It worked.
About this, I ended up just leaving it as it was and changing the inventorybox to 1 slot, using rawimages to show the previous and next items.
If anyone is looking for an answer to this, I used these instructions and attached the script to the canvas, I didn't have to do anything else, it works with the wheel and direct navigation now.