2
\$\begingroup\$

I'm using the new SceneManager to load multiple scenes in the same structure adopting the Additive method. I find it extremely useful but I wonder if there is a way to get all the GameObjects for a specific scene. When multiple scenes are loaded I see the GameObjects clearly separated by scene in the hierarchy but I cannot find a way to access the specific hierarchy of a single scene via script. Is that possible? The findGameObject method I think returns the GameObjects for all the scenes..

\$\endgroup\$
4
\$\begingroup\$

You can get all the root Game Objects of a specific scene using SceneManagenent, that will return an array of GameObject.

GameObject[] _rootGameObjectsOfSpecificScene = SceneManager.GetSceneByName("YOUR_SCENE_NAME").GetRootGameObjects();

Replace YOUR_SCENE_NAME with your scene name.

\$\endgroup\$
  • \$\begingroup\$ What version did this show up in? It doesn't appear to exist in 5.3.1. \$\endgroup\$ – Almo May 7 '16 at 20:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.