Hi everyone, I'm making a game with the direct movement method using a keyboard or controller. I'm trying to make an Inventory that can be shifted to the next item by moving left/right without clicking the Next/Previous buttons.
I found this post but don't know where to put the script. Could you help me with more details?
https://adventurecreator.org/forum/discussion/11086/inventory-scrolling-without-buttons
Thanks a lot!
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
You can place the code inside a public function, and then call that function from an ActionList.
Try this:
Copy/paste into a C# script named InventoryShifter, then attach to an empty GameObject, make it a prefab, and remove from the scene.
Then, create a pair of ActionList assets (one for left shift, one for right), and have them run an Object: Call event Action that calls the prefab's ShiftLeft/ShiftRight functions respectively.
To have these ActionLists then run when an input is pressed, assign them in Active Inputs - which can then be enabled/disabled at runtime using the Input: Toggle active Action.
Sorry Chris. I described it as not clear. I only want the inventory to shift left/right when I reach the first/last item displayed.
Also I got this error when trying your solution
https://drive.google.com/file/d/1g1Vp8bJlZi2NfXFu_LHeTnV5SyFad8be/view?usp=sharing
Thanks a lot!
You'd need to amend the "MyMenu" and "MyInventoryBox" strings with the names of your game's Menu and InventoryBox elements.
A trick to achieve this is to have the Shift Left/Right buttons be a part of your Menu/UI, but then keep them hidden off-screen.
Then, update your first/last Inventory slot Button Navigation settings to have them select these Shift buttons (i.e. pressing Right input in the last slot navigates to the ShiftRight button).
Next, rely on a custom script that - when the Shift buttons are selected, shift the Inventory, and re-select the previous Inventory slot.
You can do this with an ActionList asset as before - the re-selection can be done with the Menu: Select Action.
To run the corresponding asset when the Shift button is selected, attach this script:
I get the idea but don't know where to attach this script. Is it for Unity UI? I'm still using AC Menu for the inventory. I'll switch to Unity UI if it's the only way to achieve it.
You'd need to use Unity UI, yes. The script would be attached to the ShiftLeft/Right buttons in the UI's Hierarchy. They wouldn't need to be linked to AC's Menu Manager, however.