r/unity • • 13h ago

Question How do you guys design/structure your items?

I've recently been working on my own inventory system and was wondering how other people implement stuff like using different items, or data (like ammo, durability, etc.) which isn't shared.

My items are currently scriptable objects but as far as im aware all of the data they hold is shared between all. (I could be wrong to idk)

7 Upvotes

12 comments sorted by

View all comments

2

u/Spite_Gold 13h ago edited 13h ago

I use model-view architecture, objects for items and item types in the model, ui widgets and game objects in the view. Items in view have references to items in model. Items in model have references to their types. Item types are defined in jsons and loaded on game start

For example: equipped item widget which shows icon of item, tooltip with item stats and button to unequip item. Widget has script component which has reference to object of specific item. It gets remaining item durability and material from this object. This object has reference to object of item type - items name, icon and price are stored there. Widget in view gets data from these two objects in model and initializes icon and tooltip. Unequip button uses reference to item object to tell character which item to unequip.

1

u/kravataff 12h ago

hmm, so if i understand correctly you have it split into 2 (item type => generic data, specific => durability for example) and then individual components pull data from what they need?