You can reference content in ScriptableObject root assets in the following ways:
Loadable<T> reference to load on demand at runtime.LoadableSceneId reference to load scenesA Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. More infoLoadable references for all assets.You can also use untracked references to discover assets that only exist at runtime.
You can use Loadable<T> on classes derived from MonoBehaviour or ScriptableObject to establish on-demand references from one object to another. A loadable reference means that the referenced object doesn’t need to be loaded immediately, but it’s automatically included in the build output.
The Loadable<T> class contains a LoadableObjectId that references another object based on where the referenced object is serialized in the source project.
LoadableSceneId is similar to LoadableObjectId, but you can use it to reference a scene to bring scenes into a build and load them. There’s no direct reference type for pointing to a scene, and you must load scenes on-demand through calls to the SceneManager API. For more information, refer to Include scenes in a content build.
Direct references are the most common type of reference used in Unity.
An example of a direct reference is the link between a GameObjectThe fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObject’s functionality is defined by the Components attached to it. More info
See in Glossary and one of its components. Objects with direct references between them are usually placed in the same serialized file, because they all need to be loaded together.
For more information, refer to Direct reference asset management.
Tracked references are direct references, Loadable<T>, or LoadableSceneId fields on a ScriptableObject, MonoBehaviour, or other serialized objects. When Unity builds a content directory, it follows those fields and includes the referenced assets automatically.
An untracked reference is when your application depends on content at runtime, but nothing in the serialized data tells the build pipeline about that dependency. Instead, your code finds the content later, for example by calling ContentLoadManager.GetRootAssets<T> and reading fields on the root asset it finds.
You can use untracked references when you want to split content across content directories to create a small Player with bootstrap code that discovers root assets at runtime.
To make untracked references work in your project, do the following:
ScriptableObject to rootAssetPaths when you run BuildPipeline.BuildContentDirectory.Avoid untracked references for simple single build projects where every dependency can be a direct or Loadable reference on objects in the Player or bootstrap scene.
Using untracked references means that it’s easier to miss a dependency. For example, the Unity Editor can still use project assets if you forget to build or register the content directory, while a Player build fails until the content directory is built, shipped, and registered. In the AssetBundle system, this functionality is similar to loading by address or AssetBundle name in code without assigning the asset in the InspectorA Unity window that displays information about the currently selected GameObject, asset or project settings, allowing you to inspect and edit the values. More info
See in Glossary.