Select your preferred scripting language. All code snippets will be displayed in this language.
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.
CloseTranslates an instance ID to a reference to an object.
If the object is not loaded from disk, loads it from disk.
// Simple editor window that prints on the console the GameObject // name given an ID. // If no objec is found it prints an error. class EditorUtilityInstanceIDToObject extends EditorWindow { var id : int; @MenuItem("Examples/ID To Name") static function Init() { var window = GetWindow(EditorUtilityInstanceIDToObject); window.position = Rect(0,0,160, 60); window.Show(); } function OnGUI() { id = EditorGUILayout.IntField("Instance ID:",id); if(GUILayout.Button("Find Name")) { var obj = EditorUtility.InstanceIDToObject(id); if(!obj) Debug.LogError("No object could be found with instance id: " + id); else Debug.Log("Object's name: " + obj.name); } } }