SceneManager.sceneLoaded event when fired checking scene.isLoaded = false


Building a game in where I want to remove any conflicting camera’s from additive scenes when loaded in VR.
The VR_Loader scene is the only camera I want. This issue, however, is I haven’t found a way to detect when a scene is actually loaded (Children can be manipulated) I thought sceneLoaded would be the ticket but as you can see the scene is not actually loaded when the sceneLoaded event is fired.
This is very contradictory to what the event handler states to me. Is this a bug? Using 5.5.0b1 Personal.

So I fixed this by breaking it into a coroutine but it still seems like a bug? No?
Here is the working code:

    //Only available in Beta Unity 5.4+
    private void SceneLoaded(Scene scene, LoadSceneMode m){
        //Check other scenes and remove their main camera.
        if(scene.name != "VR_Loader") {
            StartCoroutine(RemoveCamera(scene));
        }
    }

    private IEnumerator RemoveCamera (Scene scene){
        yield return new WaitForEndOfFrame ();

        GameObject[] objects = scene.GetRootGameObjects ();
        foreach(GameObject obj in objects){
            if (obj.name.Contains ("Camera")) {
                DestroyImmediate (obj);
            }
        }
    }
1 Like

bumping this thread again, as I’m seeing this issue again in 2020.2 (possibly earlier versions as well). I’ve added a comment to the bug report.

This seems to be the case still before Start() is called when playing in the editor. This can be easily reproduced by checking SceneManager values inside RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad) functions.