- Home /
How to use ScriptableObject for Inventory System
There are two ways that came on my mind and I think both of them have some pros and cons:
In both ways I have Item class that derives from ScriptableObject and several subclasses (such as Weapon, Jewelry) with various functionality.
A) Make a Dictionary of Instantiated ScriptableObjects
dictionary.Add("name", ScriptableObject.CreateInstance("Weapon", otherVariables,...);
(so dictionary with around thousand entries) And when I need specific item I just search in the dictionary.
B) Make each Item as a separate script
item1 = ScriptableObject.CreateInstance("Item1"); item2 = ScriptableObject.CreateInstance("Item2");
The pro here is, I would be creating instance of only those items I actually need in the moment + better flexibility in general.
The question is what is better solution concerning performance and other things? I went for solution b, since it seemed to me more flexible way.