I have a script ‘ItemBase’, and within this script a class object called ‘Item’, which can be any number of different classes inheriting from a class ‘ItemType’.
I want to be able to create prefab items by creating a gameobject with the ItemBase script, and then selecting the appropriate ItemType class to the Item object. How can I do this?
The reason ItemType is a regular class (and not a monobehaviour) is that I need to be able to change it between different sub-classes of ItemType on the fly due to the core game mechanic (turning objects into other objects with different behaviours).
The only solution I can think of is to create an extra (monobehaviour) script for each of my item types, and hold the relevant object in that script, then my ItemBase script can grab that object for the Item variable. But this seems clumsy and complicated.