Polymorphic array inside ScriptableObject,Polymorphic array in ScriptableObject
Hi everybody,
I'm actually working on a project that simulates the construction of an structure, so there are construction activities, and different types of occurrences (one-time, persistent and questions) which, in turn, may influence simulation values such us budget respect, project duration, etc... (some of them are hard-coded, as they have specific behaviours, some of them can be added by using the mother class).
So far, I've coded it in a way that all these objects (activities and simple/persistent/question occurrences) are ScriptableObjects that can be created, modified and configured from Unity Editor. However, as the project gets bigger and more complex, I also have to define more complex interactions between events, sim values and activities, and here is when I started to doubt about the whole approach I'm taken.
Now, my problem arises when an event (simple one-time event for instance) may have impact on a sim value, or in a specific activity if its being done, or in whichever activity is being executed when this event takes place. Therefore, I can define different types of Effects (simple, general delay, activity-delay etc...) that derive from a abstract class/interface. However, I run into the issue that, how can the user define them from editor inside the Occurrence ScriptableObject?
1 approach: I can put different a list for every type of effect, so we have the SimpleEffects list, the DelayEffects List and so on. 2 opt: Configuring a customised editor for the class in a way that it acts as a constructor... so by means of a drop-down, the user can define the effect. 3: create effects as separate scriptable objects and add them to the list. These could be valid, but also very messy and time-consuming to create one by one in the editor.
What do you think? Perhaps the mistake is the fact of basing everything on ScriptableObjects? It's my first time I used them, and I though could be a nice alternative to create a simulator/framework...
Your answer
Follow this Question
Related Questions
Does loading a ScriptableObject on runtime and modifying it affect the ScriptableObject in file? 1 Answer
Scripting Movement Fails for Instantiated Prefab 2 Answers
Items/Inventory system using Scriptable Objects and Composition instead Inheritance. 0 Answers
What is the benefit of creating a scriptable object? 2 Answers
[SOLVED] ScriptableObject generic list makes all derived instances to base type when serializing 1 Answer