Using scriptable objects
In the previous examples, the art info data is maintained on a GameObject in the Scene Hierarchy. As a software design, this is not really where the data belongs. Data objects are not game objects and should be managed separately.
In the Scene hierarchy, we define the level design and game behaviors. ArtworkRigs have spatial coordinates (Transform) and renderers (and other potentially necessary runtime components such as colliders and RigidBodies for physics). But other data, still a project asset, can live outside the scene hierarchy. For this, Unity offers ScriptableObjects. We first introduced ScriptableObjects in Chapter 5, Handy Interactables, as a way of sharing input data across game objects. We will use them ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access