Search Unity

GetRootGameObjects for unloaded scenes?

Discussion in 'Editor & General Support' started by NeonTheCoder, Apr 9, 2018.

  1. NeonTheCoder

    NeonTheCoder

    Joined:
    Feb 1, 2014
    Posts:
    40
    Hi, I have an editor extension that I have been working on that I am using for serilization purposes, and to get references for objects. Basically I have an ID library and some Monobehaviors I have, have an ID attached to them. So I am looking for a way to look through all scenes that are in the build (I do this through a World Asset that has other information about the scene) and get all IDs from objects but GetRootGameObjects seems to only work for loaded scenes. So I am wondering if there is a different solution?
    Also this is the code I am using:
    Code (CSharp):
    1. List<World> worldsInProject = new List<World>(Resources.FindObjectsOfTypeAll<World>());
    2. List<GameObject> allObjects = new List<GameObject>();
    3.  
    4. foreach (World w in worldsInProject) {
    5. allObjects.AddRange(SceneManager.GetSceneByName(w.WorldScene.name).GetRootGameObjects());
    6. }
    And the error I am getting is "The Scene is Invalid"