0

My scene has a list of individual Module. Those modules can have different data associated with them and also different logic, so I decided to create several derived classes from Module and store them in a list. By making Module inherit from SerializableObject, I can create module of any derived type and store that in my list.

Is this considered a bad desing? Am I making Bad use of Scriptable Object or missing something? The goal of this is to be able to create derivedModules and make them fully serializable in Unity's Editor.

Naturally all derived modules share the same logic defined in parent's class

class Module : ScriptableOBject{
...
}

class ModuleX : Module{
   public int SpecificDataForModuleX = 0;
...
}
Icaro Amorim
  • 385
  • 1
  • 3
  • 13

1 Answers1

0

In unity, it is OK to do it this way. If we were able to use interfaces to store a list of objects that would be better. But it is impossible in regular unity without additional workarounds.