I ran into ScriptableObjects recently, but I am not sure if I understand them correctly.
In my case I have an Attack class, which holds a timeline with frame data on which hitboxes should be spawned, etc.
I have written an editor extension to manipulate the timeline, add frames, determine framerate, etc.
Since this class is not a component, and it simply holds data, I thought it would be handy to let the extend the ScriptableObject class.
Everything went fine until I actually wanted to use the damn thing in runtime. I have a component that wants to get a copy (instance?) of this Attack class, with all the values that have been saved into this Scriptable Object so it can playback the Timeline class during an attack.
However, whenever I try to use ScriptableObject.CreateInstance(), all the fields are null.
Maybe I’ve misunderstood, and the ScriptableObject is only used to store data, and I should just feed the data manually into a new Attack class instance that I create in the component.
I’d like to simply use this ScriptableObject as some sort of prefab for a class, just being able to get a copy of the Attack with the variables as listed, and then directly reference the instance in the component.
Am I trying to do something unintended, should I somehow use a prefab for this, or did I simply implement the ScriptableObject incorrectly?
Thanks!