What Are Scriptable Objects In Unity?
Scriptable Objects are a great feature of Unity. They allow the storing of data independent from GameObjects, MonoBehaviours, Scenes, and any sort of save file.
A Scriptable Object is a data container that you can use to save large amounts of data, independent of class instances. — Unity Documentation
The main use cases for Scriptable Objects are:
- Saving and storing data during an Editor session.
- Saving data as an Asset in your Project to use at run time.
Coding a Scriptable Object:
A Scriptable Object is written similar to a normal monobehaviour. However, it must inherit from the UnityEngine.ScriptableObject base class.
You may choose to add the CreateAssetMenu Attribute too. It makes creating SO instances easier, by adding an entry into the Create menu (Right-Click in Project panel).