LoadSceneAsync() callback not firing until a frame late [bug?]

I have noticed a possible issue with Addressables.LoadSceneAsync() and its callback. I need to disable a particular gameobject whenever the scene is loaded, but the callback from LoadSceneAsync() isn’t being called until possibly a frame late, which is presenting an issue. I’ll provide an example below which shows the issue.

Say I have scene2 being loaded, which has a gameobject with TestScript attached to it.

Addressables.LoadSceneAsync("scene2").complete += delegate {
    print("Scene2 loaded via addressables.");
};
//Testing SceneManager behavior below.
SceneManager.sceneLoaded += delegate {
   print("scene loaded.  Called from sceneLoaded callback.");
};


//Inside of the TestScript Start method looks like the following:
void Start() {
     print("Start called on object in scene2.");
}

The output from the above code is as follows:
-scene loaded. Called from sceneLoaded callback.
-Start called on object in scene2.
-Scene2 loaded via addressables.

I’m not sure if this is the intended behavior, but it seems to me that Start() on the TestScript should be getting called last. SceneManager.sceneLoaded seems to get called when expected (first) but I’m not sure the Addressables.LoadSceneAsync callback should be last.

I can work around this by using the sceneLoaded callback, but it’d just be a bit tidier if I could use the Addressables callback instead. I also wanted to point this out incase it wasn’t intended so it could be fixed.

Thanks for flagging! I’ll circulate this with the team!

Thanks for bringing this up. I’m fairly certain, due to our async behavior relying on the SceneManager.LoadSceneAsync to actually load the scene I don’t know if there’s realistically anything we can do about it. But we definitely can look and see.

Thanks for the response. Yea I wondered if maybe it had something to do with it being async. I did find another bug in my code related to this issueas well, so looks like I’ll have to change to the scenemanager callback for it as well. I do think this will be an issue for other developers too, so if a fix could be found it’d probably be for the better. :slight_smile: