3
\$\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\$

1 Answer 1

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\$
1
  • \$\begingroup\$ What version did this show up in? It doesn't appear to exist in 5.3.1. \$\endgroup\$
    – Almo
    May 7, 2016 at 20:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .