Creating an Item Database.


I’m new to Unity and C#, and i’m currently working on my first project ( tons of tutorials doesn’t count ! ).

I’m building up an Item Database, so I created an Item abstract class which is extended by Weapons ( also abstract and extended by different classes such as Sword, … ), Consumables, etc.

I created an ItemDatabase class which is supposed to handle EVERY single item in my game, no matter if it’s a weapon or a consumable, it only needs to be a child of Item.

So, in my ItemDatabase I created a List of Items … but this is the problem :

Since Items is an abstract class I can’t and don’t want to instantiate an Item Object … I want to create a weapon or a consumable.

I know I could add new methods to the Editor, to directly add a new item in the database, but … items will not be sorted.

To be more explicit that’s what I want to see in my inspector :


Lists can’t handle more than one type, so could I use List to do that ?

Thanks a lot for your help !

NB : sorry if my english isn’t that great.

I suggest that you use ScriptableObjects to manage your Items.
Make your base Item class a child of the ScriptableObject class and then make your weapon/consumables… subclasses.

Then you can add the attribute [CreateAssetMenu()] to your Swords class, Bows and so on. After that if you right click in the project folder you can create actually assets of Swords, Bows… and assign it values from the inspector. Then in your ItemDatabase you just have lists referencing those assets:

public class ItemDatabase : ScriptableObject {
     public List<Swords> swords;
     public List<Bows> bows;
     public List<Spears> spears;
     public List<Potions> potions;