Unity-Resource-Checker icon indicating copy to clipboard operation
Unity-Resource-Checker copied to clipboard

Multiple Scenes in Hierarchy with only one loaded throws "scene not loaded"

Open jnbbender opened this issue 4 years ago • 1 comments

When multiple scenes are in the Hierarchy the Checker will throw a "scene not loaded exception". This occurs regardless of whether or not they are listed in your Build Settings.

jnbbender avatar Jan 16 '21 16:01 jnbbender

The issue is at line 957. A check needs to be made to determine if the Scene is loaded or not. Change the for loop to...

    for (int sceneIdx = 0; sceneIdx < UnityEngine.SceneManagement.SceneManager.sceneCount; ++sceneIdx){
        Scene scene = UnityEngine.SceneManagement.SceneManager.GetSceneAt(sceneIdx);
        if (scene.isLoaded)
        {
            allGo.AddRange(scene.GetRootGameObjects());
        }
    }

There were also too many ToArray() calls.

jnbbender avatar Jan 16 '21 16:01 jnbbender