I have a inventory and I need to add a hotbar to access certain items.

What this hotbar needs to do is when in the inventory "Menu" you add items to it and when you close the menu the hotbar moves to the bottom of the screen and you select and item, weapon, food ect, and can use it (like in Minecraft).

My problem is I don't know whether I should:

  1. Keep track of which items are in hotbar "spaces" of the inventory and use them accordingly, or

  2. Make a separate list for hotbar items and move them between the inventory and hotbar lists when needed

or a third way I did not even think of.

My inventory works by having items in a list. The item class has values such as dmg, uses, name, etc. I have an item data class I put on GameObjects that has a public item variable. I have an inventory UI class that takes the inventory list and displays them.

  • \$\begingroup\$ I'm sorry, but this question is impossible to answer without knowing how your inventory system works. There is no standard solution for creating an inventory system in Unity, which means there is no standard solution for adding a hotbar to it either. \$\endgroup\$
    – Philipp
    Jun 27, 2018 at 7:51
  • \$\begingroup\$ @Philipp i have edited my question it explain my inventory system more. \$\endgroup\$ Jun 27, 2018 at 14:18
  • \$\begingroup\$ Both routes you list seem like they'd work. In option 1 you'd need to make sure to maintain placeholders or fix up the links in the event that your inventory list changes (say you have a hotbar slot pointing to potions, then you use all your potions. You don't want that slot to now point to an invalid entry or to the next item in the list). In option 2 you'd need to ensure that any operations you perform on the inventory (like searching for an item to use/take/increment) process both lists. Which one makes more sense for your development practices is something you'll need to decide yourself. \$\endgroup\$
    – DMGregory
    Jul 3, 2018 at 16:05
  • \$\begingroup\$ if your game like a final fantasy, where you can have seemingly infinite items in a list? Or is your game more like minecraft where you can have an inventory which is different than the 'helm slot' which is different than the 'armor slot' which is different than the 'boots slot' etc. Depending on what you are doing, your answer will be different. If it is the first way, then doing it all in one list is best, if doing it the second way, then having a class with a list<item> for the inventory and a item for the helm, and an item for armor, might be way better. \$\endgroup\$ Jul 4, 2018 at 21:51

1 Answer 1


I went with number 2 and made methods to move items around like inventory to hotbar and hotbar to inventory. This post helped to make the swaping methods


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .