I’ ll try to share some technical details on ScriptableObject class in this blog series. Also share some use cases that we use in our workflow in DreamHarvesters.
ScriptableObject is a serializable Unity class. While not supporting most of the callbacks that MonoBehaviours do, ScriptableObjects tend to be used mostly as data classes.
Another difference is, while MonoBehaviours live in the scenes, ScriptableObjects live in the project. Thus, changes in the ScriptableObject while the editor is in play mode, all the changes persist so you won’ t lose any of them.
They’ re, unfortunately, not used widely in the ecosystem as far as i know. This is sad because ScriptableObjects has very wide range of usage scenarios. I suppose this happens because the tutorials and docs mention MonoBehaviours heavily. That’s quite understandable. People that just start using Unity would like to make something fast. This is why MonoBehaviours are promoted in the resources.
ScriptableObjects, on the other hand, offers many different usages which speed up the prototyping/development periods. Unity also depends on ScriptableObjects for its internal system(for instance the Scriptable Build Pipeline). It’ s much easier developing subsystems with ScriptableObjects.
Let me outline the basic properties of Scriptable Objects:
- They’ re serialized
- Possible creating asset files of Scriptable Objects
- Does only receive OnEnable, OnDisable, OnValidate, OnDestroy and some other callbacks of Unity. (see: https://docs.unity3d.com/ScriptReference/ScriptableObject.html)
- Lives in the project not in the Scene
I’ ll write on some of the use cases in the coming articles like:
- Basic usages of Scriptable objects
- Variable system with Scriptable objects
- Event system with scriptable objects
That’s all for now,