Get game objects from other scenes

Hi guys do we have a way of getting objects from scenes we are not in, i will be doing this from an editor window so it doesn’t need to be at runtime or anything.

I’m looking for something like below but to return stuff in other scene hierarchies as well as the one I’m in.
GameObject[ ] obj = Resources.FindObjectsOfTypeAll(typeof (GameObject)) as GameObject[ ];

Thanks.

What about SceneManager, GetSceneAt/GetSceneByName, and GetRootGameObjects?

Or, since you’re doing it in the editor, you could look at this one: EditorSceneManager. Seems to have similar functionality.

Excellent, thank you :slight_smile:

SceneManager and the likes still mean you have to load the scene before examining the objects in it.

I recall someone in the past telling me about: InternalEditorUtility.LoadSerializedFileAndForget
This takes an Object as parameter (load the scene file using AssetDatabase.LoadAssetAtPath) and then pass that object into this method.

The result is an array of objects that are in that scene, although results may vary from not working to crashing your editor from my personal experience…