So I have an ItemDatabase
class which basically only has a list of Item
public class ItemDatabase : MonoBehaviour {
public List<Item> Items = new List<Item>();
}
The Item
class looks as follows:
[System.Serializable]
public class Item {
public string Name;
public int Id;
public string Description;
public Texture2D Icon;
}
Now I have some item types deriving from the Item
class, for example Consumable
[System.Serializable]
public class Consumable : Item {
public int Resore;
}
I next created a gameobject (empty) in my editor and hooked up my ItemDatabase
to that object, providing a number of items in the list is no problem but I would like to make sure that - from my editor - I can choose a type of Item to put into the list, as of now, it only lets my add Item
and not Consumable
because it is a list of Item
.
Can I also force the editor not to accept just Item
by making it an abstract class?