void FindAllGameObject() {
List<GameObject> roots = new List<GameObject>();
for (int i = 0; i < SceneManager.sceneCount; i++)
{
var scene = SceneManager.GetSceneAt(i);
if (!scene.isLoaded) continue;
roots.AddRange(scene.GetRootGameObjects());
}
for (int i = 0; i < roots.Count; i++) {
print(roots[i].name);
}
}
网友评论