private Object EditorResolveSlow() { var scene = this.scene.scene; if (!scene.IsValid()) { return(null); } if (!scene.isLoaded) { return(null); } // Find the object (this is potentially very slow). Object[] allObjs = EditorUtility.CollectDeepHierarchy(scene.GetRootGameObjects()); foreach (var obj in allObjs) { // Apparently this happens... bummer if (!obj) { continue; } // If it's a prefab, it's a lot more difficult since Unity doesn't store IDs var prefabObj = PrefabUtility.GetPrefabObject(obj); if (prefabObj && editorLocalId == GetEditorId(prefabObj)) { GameObject gameObject = GameObjectEx.EditorGetGameObjectFromComponent(obj); if (!gameObject) { Debug.LogWarningFormat(obj, "Could not SLOW resolve {0} (cross-scene reference is broken). Pointing it to {1}.", this, obj); return(obj); } // Make sure we do this from the root var prefabRoot = PrefabUtility.FindPrefabRoot(gameObject); if (prefabRoot) { gameObject = prefabRoot; } // If we have a relative path, grab that GameObject if (!string.IsNullOrEmpty(editorPrefabRelativePath)) { Transform transform = gameObject.transform.Find(editorPrefabRelativePath); if (transform) { gameObject = transform.gameObject; } else { Debug.LogWarningFormat(gameObject, "Tried to perform a slow resolve for {0} and found prefab {1}, but could not resolve the expected sub-path {2} which indicates the Prefab instance path was renamed.", this, gameObject, editorPrefabRelativePath); } } Debug.LogWarningFormat(gameObject, "Performed a slow resolve on {0} due to a rename. We found PREFAB with same ID named {1} (but we're not sure). Attempting a resolve with it.", this, gameObject); fullPath = GameObjectEx.GetFullName(gameObject); return(RuntimeResolve()); } else if (editorLocalId == GetEditorId(obj)) { GameObject gameObject = GameObjectEx.EditorGetGameObjectFromComponent(obj); Debug.LogWarningFormat(obj, "Performed a slow resolve on {0} and found {1} ({2}). Double-check this is correct.", this, gameObject ? gameObject.GetFullName() : "(Non-Existant GameObject)", obj.GetType()); return(obj); } } return(null); }