Creating and managing Scriptable Objects
As developers, we usually need to store and load data persistently. We've probably used some formats in the past, such as XML, JSON, and CSV via text files. As such, we know it takes development time to support changes and iterations throughout the project. Much of this data is used to set up the game and shape levels, enemies, and the whole game mechanics.
As Unity developers, we harness the power of the Inspector window via public/serialized member variables; however, it makes more sense to store these values in a persistent file—that's why the ScriptableObject
class exists. In this recipe, we will be exploring its value.
Getting ready
We will illustrate the use of the ScriptableObject
class by working it out as part of the recipe, Implementing an architecturefor racing games; however, it has its own place because we believe it's important to bring to the table the reasoning behind the use of the ScriptableObject
class.
How to do it...
- Firstly, create...