Recently I have started implementing an Item System into my game. The Items are stored into a ScriptableObject (InventoryItemDB) which can then be used to access the stored Items.
The current goal is to display the Inventory correctly, but I have several options on how I could do that:
- Let the ItemButton class have a function that fetches the Data from the InventoryItemDB based on an index variable that is assigned on start
(Button1:index=0, Button2:index=1, etc.) - Have an Event that is called whenever the UI should update. The event has the inventory as an argument and each itemButton,
based on an index variable (see option 1), picks the correct item out of the inventory (using the index). - Have a separate InventoryEventHandler that, when called, assigns each itemButton the correct itemData and then calls an itemButtonDisplayUpdateEvent (if required)
My goal here is to decouple the code as good as I can but also to stay on the performant side of things.
What would you recommend? Is there different approach to this as well? - Thanks in advance!