# LoadableObjectId

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

## Definition

* **Type:** Struct
* **Namespace:** [Unity.Loading](/engine/6000.7/script-reference/unity/loading.md)
* **Assembly:** UnityEngine.CoreModule
* **Implements:** [IEquatable\<LoadableObjectId>](https://learn.microsoft.com/dotnet/api/system.iequatable-1)

```csharp
public struct LoadableObjectId : IEquatable<LoadableObjectId>
```

## Remarks

LoadableObjectId is the underlying reference type used by [Loadable\<T>](/engine/6000.7/script-reference/unity/loading/loadable1.md). It contains the information needed to identify and load a specific object from built content.

In the Editor, use [LoadableObjectIdEditorUtility](/engine/6000.7/script-reference/unityeditor/loadableobjectideditorutility.md) to create LoadableObjectIds. Typically these are serialized as part of [Loadable\<T>](/engine/6000.7/script-reference/unity/loading/loadable1.md) fields on classes derived from [ScriptableObject](/engine/6000.7/script-reference/unityengine/scriptableobject.md) or [MonoBehaviour](/engine/6000.7/script-reference/unityengine/monobehaviour.md). You can also use LoadableObjectId directly as a field type in a ScriptableObject or MonoBehaviour, and then create [Loadable\<T>](/engine/6000.7/script-reference/unity/loading/loadable1.md) objects on the fly as needed.

Using LoadableObjectId directly suits a root asset that acts as a library of assets shared by several components. Because LoadableObjectId has no load or release methods of its own, it makes clear that each caller constructs its own [Loadable\<T>](/engine/6000.7/script-reference/unity/loading/loadable1.md) and owns the lifetime of the object it loads.

LoadableObjectId has no generic type parameter, so it can reference any [Object](/engine/6000.7/script-reference/unityengine/object.md). Add your own validation if a field must only accept a specific type.

When those objects 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](/engine/6000.7/script-reference/unity/loading/contentloadmanager.md) resolves LoadableObjectIds to the correct built content as long as it is part of the currently registered content directories.

A LoadableObjectId is only supported in content built with [BuildPipeline.BuildContentDirectory](/engine/6000.7/script-reference/unityeditor/buildpipeline/buildcontentdirectory.md). If a LoadableObjectId is found in serialized data during a Player or AssetBundle build, the reference is set to null in the build output and an error is logged. Suppress this error with [BuildOptions.SuppressLoadableErrors](/engine/6000.7/script-reference/unityeditor/buildoptions/suppressloadableerrors.md) for Player builds or [BuildAssetBundleOptions.SuppressLoadableErrors](/engine/6000.7/script-reference/unityeditor/buildassetbundleoptions/suppressloadableerrors.md) for AssetBundle builds.

Additional Resources: [Loadable\<T>](/engine/6000.7/script-reference/unity/loading/loadable1.md), [LoadableObjectIdEditorUtility](/engine/6000.7/script-reference/unityeditor/loadableobjectideditorutility.md)

## Examples

```csharp
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](/engine/6000.7/script-reference/unity/loading/loadableobjectid/isvalid.md) | True if this LoadableObjectId is initialized with valid data. |

## Methods

| Method                                                                                 | Description                                               |
| -------------------------------------------------------------------------------------- | --------------------------------------------------------- |
| [ToString](/engine/6000.7/script-reference/unity/loading/loadableobjectid/tostring.md) | Returns a string representation of this LoadableObjectId. |
