The ContentLoadManager offers APIs for accessing content that has been built. It is primarily used to register content directories and access root content.
In the Editor this is not typically used, because the content is available directly in the project using
AssetDatabase and EditorSceneManager calls.
However, it can be useful in Editor play mode to run the same loading case as the runtime and to try out the
output of your Content Directory build, directly inside the Editor.
Additional resources: Loadable<T0>, LoadableSceneId, BuildPipeline.BuildContentDirectory
using Unity.Loading; using UnityEngine;
namespace BuildDocExamples { public class ContentLoadManager_GetRootAssetsExample : MonoBehaviour { // Example catalog ScriptableObject with a Loadable field public class MyContentCatalog : ScriptableObject { public Loadable<Texture2D> previewIcon; }
void Start() { // After deploying a content directory next to the player, register it once at startup: var handle = ContentLoadManager.RegisterContentDirectory("/path/to/BuiltContent"); foreach (var catalog in ContentLoadManager.GetRootAssets<MyContentCatalog>()) { catalog.previewIcon.Load(); try { Texture2D icon = catalog.previewIcon.Target; // Use the icon... } finally { catalog.previewIcon.Release(); } } ContentLoadManager.UnregisterContentDirectory(handle); } } }
| Method | Description |
|---|---|
| GetContentDirectories | Retrieves an ordered list of content directories. |
| GetRootAssets | Retrieve all root assets of a specific type from all registered content directories. |
| RegisterContentDirectory | Add the built-content in a directory to the ContentLoadManager. This makes it possible to load the contained Scenes and Assets. |
| UnregisterContentDirectory | Remove access to content that had been loaded from a content directory. |