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.