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

LoadableObjectIdEditorUtility

class in UnityEditor

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

Editor utilities for creating and converting LoadableObjectId values when authoring content.

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.

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
CreateLoadableObjectId Creates a LoadableObjectId from a Object that can be used for on-demand loading.
LoadableObjectIdToObject Retrieve the Object referenced by a LoadableObjectId.
TryDeconstructLoadableObjectId Deconstructs a LoadableObjectId into its component parts: GUID, local file identifier, and file identifier type.