Quantcast
Channel: Answers for "Finding the root GameObjects in the scene ?"
Viewing all 22 articles
Browse latest View live

Answer by nsmith1024

$
0
0
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 never shows up, even if I duplicate another object of the same time, the duplicated object does not appear in the array returned by that line of code, even though its active in the scene. I think unity has a bug there.

Answer by dbdenny

$
0
0
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: UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects().Where(r => (r.hideFlags & HideFlags.HideInHierarchy) == 0);
Viewing all 22 articles
Browse latest View live


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