Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


LoadableObjectIdEditorUtility

Editor utilities for creating and converting LoadableObjectId values when authoring content.
Read time 1 minuteLast updated 4 days ago

Definition

  • Type: Class
  • Namespace: UnityEditor
  • Assembly: UnityEditor.CoreModule
public static class LoadableObjectIdEditorUtility

Remarks

LoadableObjectId is the low-level reference type used by Loadable<T> for on-demand object loading. These methods convert between live Object instances and serialized loadable object IDs for content directory builds.
Use this utility to populate a root asset or a LoadableObjectId field from a script. It is also useful when implementing custom Editor UI for ScriptableObjects or MonoBehaviours that contain Loadable<T> or LoadableObjectId fields.

Examples

using Unity.Loading;using UnityEditor;using UnityEngine;namespace BuildDocExamples{ // Example showing how to use LoadableObjectIdEditorUtility to convert between Objects and LoadableObjectIds public class LoadableObjectIdEditorUtility_Example { public void ConvertObjectToLoadableObjectId() { // Load an asset from the AssetDatabase Texture2D iconTexture = AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/Icon.png"); // Convert the Object to a LoadableObjectId LoadableObjectId iconId = LoadableObjectIdEditorUtility.CreateLoadableObjectId(iconTexture); // Now iconId can be serialized on a ScriptableObject for content directory builds } public void ConvertLoadableObjectIdToObject() { LoadableObjectId iconId = new LoadableObjectId(); // ... (iconId would typically be loaded from serialized data) // Convert the LoadableObjectId back to an Object in the Editor Object obj = LoadableObjectIdEditorUtility.LoadableObjectIdToObject(iconId); if (obj is Texture2D texture) { // Use the texture in the Editor Debug.Log($"Loaded texture: {texture.name}"); } } }}

Static Methods

Method

Description

CreateLoadableObjectIdCreates a LoadableObjectId from an EntityId.
LoadableObjectIdToObjectRetrieve the Object referenced by a LoadableObjectId.
TryDeconstructLoadableObjectIdDeconstructs a LoadableObjectId into its component parts: GUID, local file identifier, and file identifier type.