Scriptable Objects in Unity

The development of the second app in this course continues. And the main topic of the development of this app is just ScriptableObjects.

Scriptable Objects are amazing data containers. They don’t need to be attached to a GameObject in a scene. They can be saved as assets in our project. Most often, they are used as assets that are only meant to store data, but can also be used to help serialize objects and can be instantiated in our scenes.

To use a Scriptable Object we need to create a new script and remove the Monobehaviour and instead inherit from the ScriptableObject class.

The second important thing to do is to add the create asset command before the class so that it can be serialized in the unity menus.

Now you can create an asset in the project tab with the fields that have been declared in the Scriptable Object.

In this project, I used this tool to populate my card with different data based on the button that was pressed.

They can be used in different ways, like presets for character creation. A classic example is the D&D character sheet. To give another popular example even Heartstone cards can be made and I suppose they were made with Scriptable Objects.

project manager by day, unity developer by night