Get all the gameobjects for a SceneManager scene in Unity
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..
You can get all the root Game Objects of a specific scene using
SceneManagenent, that will return an array of
GameObject _rootGameObjectsOfSpecificScene = SceneManager.GetSceneByName("YOUR_SCENE_NAME").GetRootGameObjects();
YOUR_SCENE_NAME with your scene name.
- Database Administration Tutorials
- Programming Tutorials & IT News
- Linux & DevOps World
- Entertainment & General News
- Games & eSport