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 ...

Get Unity Virtual Reality Projects - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.