GUI Inventory system with keys (keyboard)?

Hi there,

I am working on a 2D sidescrolling game (Unity 4) that has an inventory system to store and use objects after pickup. The inventory GUI element shows squares (buttons, for now) with each item icon. The Inventory is an empty window at first, and whenever the player picks up an object, a new button appears showing the item (its icon). This game is mostly platformer, so all the input comes via the Keyboard, no mouse functions at all.

I was wondering if there’s some way to handle an inventory and its contents with keys. For now, I have things like the main menu and the pause menu completely functional with keyboard-only controls (and each option highlights correctly when I use “up” or “down”) using GUI.SelectionGrid. But with the inventory is a whole different thing. It kinda works, but with no highlighting at all (unless I hover the mouse over the buttons).

How should I proceed with this? Thx.

I’ve somehow made it work using GUI.Toolbar, but it is uneffective since it fills the whole toolbar with one big button when there’s only 1 object in my array.

If your using images for the GUI. You should swap out the current selected position with a “Highlighted” image or even just a highlight looking effect.

So you need a variable that would hold the position index of the currently selected position in the array(Inventory).
Some kind of texture/image hopefully your using a system other then Unity built in GUI.

No, I am in fact using Unity’s built-in GUI system, but it sure has its limitations.

I already thought about coding something as you say, maybe I should try it and forget about Unity’s GUI tool.