Version: Unity 6.3 Beta (6000.3)
LanguageEnglish
  • C#

EditorUtility.EntityIdToObject

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

Declaration

public static Object EntityIdToObject(EntityId entityId);

Description

Translates an EntityId to a reference to an object.

If the object is not loaded from disk, loads it from disk.


Editor Window to find an object, whose EntityId we will use to get and print the name of the object.

using UnityEngine;
using UnityEditor;

public class EntityIdToObjectExample : EditorWindow { static Object source;

[MenuItem("Example/ID To Name")] static void Init() { // Get existing open window or if none, make a new one: EntityIdToObjectExample window = (EntityIdToObjectExample)EditorWindow.GetWindow(typeof(EntityIdToObjectExample)); window.Show(); }

void OnGUI() { source = EditorGUILayout.ObjectField("Entity Id:", source, typeof(Object), true); var id = source ? source.GetEntityId() : EntityId.None; if (GUILayout.Button("Find Name")) { Object obj = EditorUtility.EntityIdToObject(id); if (!obj) Debug.LogError("No object could be found with instance id: " + id); else Debug.Log("Object's name: " + obj.name); } }

void OnInspectorUpdate() { Repaint(); } }