Quantcast
Channel: Answers for "Finding the root GameObjects in the scene ?"
Browsing latest articles
Browse All 22 View Live

Answer by Mike 3

I'd do it via Transform instead of GameObject, but otherwise no, that'll be pretty much the fastest wayIf you use Transform instead of GameObject, you can just check if t.parent is null, if so it's the...

View Article


Answer by BinaryCore

Another way is that you could also use Tags to tag your root game objects with a distinct tag type like "RootGameObject" and then use GameObject.FindGameObjectsWithTag("RootGameObject") to get all the...

View Article


Answer by yoyo

You can find a single root object like this (C#):Transform xform = UnityEngine.Object.FindObjectOfType<Transform>(); GameObject rootObject = xform.root.gameObject;Note that this calls...

View Article

Answer by Adrian

In the Unity editor (**ONLY**) ... You can use following code to get all the root game objects directly (the same method is used internally by Unity in the hierarchy window): public static IEnumerable...

View Article

Answer by rdaoushy

Transform.root

View Article


Answer by DonKanallie

With a recent Unity version (around 5.3) the preferred way would be UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects()

View Article

Answer by nsmith1024

GameObject[] p = UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects(); This doesnt work, some active objects are not included in the list. One object that im interested in...

View Article

Answer by dbdenny

UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects() Will find all gameobjects in scene (both editor mode and play mode!), so I recommend to do a filter like this:...

View Article

Browsing latest articles
Browse All 22 View Live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>