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 nsmith1024
↧
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:
UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects().Where(r => (r.hideFlags & HideFlags.HideInHierarchy) == 0);
↧
↧