A
A
Arseniy Efremov2017-01-14 20:38:39
C++ / C#
Arseniy Efremov, 2017-01-14 20:38:39

Why does Resources.LoadAsync pause scene loading?

Faced an interesting situation in Unity.
I have a scene A that has a SoundManager object (it is translated in this scene to DontDestroyOnLoad and saved as a singleton). This manager asynchronously tries to load the resource using Resources.LoadAsync, in the request I set allowSceneActivation to true , after which a coroutine starts, which waits for the loading to complete (yield) and sets the audio clip upon completion.
Nothing happens when I go to scene B, however, when I return from scene B to scene A (all this using the usual LoadScene), at the moment of the transition (while still in scene B), I again force the SoundManager to load a new resource. And here's the problem: this load operation, despite being asynchronous, prevents scene A from loading. The scene is loaded only after the resource has finished loading.
I have one guess: probably all coroutines are executed within the same active scene, and since B was active at the time of the call, naturally, it waits for the resource to finish loading, and only then starts A. Even though DontDestroyOnLoad is present at this moment and StartCoroutine is called exactly on the object from there.
Actually, the question arises, do I understand the essence correctly, and is it possible to somehow get around this situation?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question