Reputation:
I am using SceneManager.LoadSceneAsync(scene_name)
to load a scene; while I have a black image with some text on it, to tell the user that I am loading a new scene. The text is animated.
The "loading" screen has also a sound loop, so I can tell when the music stop that the new scene is ready and the old one is been disposed.
The issue is that between the moment when the music stop to play, and the other scene appear, there is a delay; wich is few seconds if I ran already the application in the editor (or as standalone, the behavior is the same), and it goes up to 10-15 seconds, if the app was not ran already.
Is there a way to figure out where the hang is happening? Using VS and breakpoints, when I go step by step, the editor won't reflect exactly what is happening sadly.
I even did create an AsynOperation, and I get 0 for AsyncOperation.progress
(which should be 1 when the scene is fully loaded), and same goes for AsyncOperation.isDone
, which return false
Upvotes: 0
Views: 170
Reputation:
I believe I did find the issue.
Basically when Unity load a new scene, it has to initialize all the elements for every game objects; and this means that if you run coroutines in the new scene; they may be triggered and take cycles.
I can't explain exactly why I get no progress at all, nor why isDone continue to be false, even after that the level is loaded.
Upvotes: 1