Version: Unity 6.6 Alpha (6000.6)
LanguageEnglish
  • C#

LoadableObjectId

struct in Unity.Loading

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

A low-level reference to an object within an asset, used to pull assets into a ContentDirectory build, and for on-demand loading.

LoadableObjectId is the underlying reference type used by Loadable<T0>. It contains the information needed to identify and load a specific object from built content.

In the Editor, use LoadableObjectIdEditorUtility to create LoadableObjectIds. Typically these will be serialized as part of Loadable{T} fields on ScriptableObject-derived classes. When those ScriptableObjects are built as part of a Content Directory, the assets referenced by the LoadableObjectId are recursively pulled into the build output. At runtime, the ContentLoadManager resolves LoadableObjectIds to the correct built content as long as it is part of the currently registered content directories.

Player and AssetBundle builds do not pull assets referenced by LoadableObjectId into the build, this is only supported by BuildPipeline.BuildContentDirectory.

Additional resources: Loadable<T0>, LoadableObjectIdEditorUtility

using Unity.Loading;
using UnityEngine;

namespace BuildDocExamples { // Example showing how LoadableObjectId is used in practice [CreateAssetMenu] public class Catalog : ScriptableObject { public LoadableObjectId iconId; }

public class LoadableObjectId_Example { public void ExampleUsage() { // In the editor, assign iconId via LoadableObjectIdEditorUtility.CreateLoadableObjectId(iconTexture); Catalog catalog = ScriptableObject.CreateInstance<Catalog>();

// At runtime, bridge LoadableObjectId to Loadable<T> for the runtime API: Loadable<Texture2D> iconLoadable = new Loadable<Texture2D>(catalog.iconId); iconLoadable.Load(); // Use iconLoadable.Target... iconLoadable.Release(); } } }

Properties

Property Description
IsValid True if this LoadableObjectId is initialized with valid data.

Public Methods

Method Description
ToString Returns a string representation of this LoadableObjectId.