Hi all,
I am developing a game for Windows Phone (8.0) and when I change scene with the LoadLevelAsync() (I have the PRO version) I call another thread with a loading screen with a simple animation.
In Unity Editor all goes well, but when I deploy a Master version on my test device it freezes when the scene actually changes.
What can I do to solve that?
Hi,
which Unity version are you on?
Hi,
I’m using the last one: 4.5.5
Does this reproduce consistently? Does it load eventually and just doesn’t display anything until then or does it totally freeze?
It actually loads the new scene. For example I can perfectly hear the music of the new scene, while the loading screen I made is freezed. Then the new scene appears, but a freezed animation for loading is actually useless.
How have you implemented the “animation”?
yes, with an external tool (NGUI).
But I launch it in another thread.
How are you launching it in another thread? Unity API is not thread safe, which means you may only access it from Unity main thread. Could you post the code?
I call the coroutine with:
private void changeToScene (string newScene){
_newSceneName = newScene;
StartCoroutine ("change");}
and the coroutine which makes the loading and the scene change is:
IEnumerator change() {
_async = Application.LoadLevelAsync(_newSceneName);
_async.allowSceneActivation = false;
while (!_async.isDone) {
if (_async.progress >= 0.9f){
_async.allowSceneActivation = true;
}
yield return null;
}
}
Coroutines aren’t actually executed in another thread. They get called on the main Unity thread.
I’m not sure what might cause this. Does the scene work correctly when you load it using Application.LoadLevel?
The scene works properly, yes (of course with the same problem).
I think it may be the internal function of scene change which blocks the mobile phone (and so even the loading animation). Is it correct? Is there a way to avoid that? On some mobile phone (such the Lumia 630, for instance) it is a serious issue, since the game could appear “freezed” to the players.
You mean the scene is black when you load it normally too? So it’s not really related to LoadLevelAsync?
nope, the scene freezes even without any loading screen (as I did before to implement that function)
What happens if you make that scene the first scene that Unity loads when you start the game?
Furthermore, do you have any image effects on the camera in that scene? I’ve seen them causing such issues in the past, though I think we did fix majority of those cases.
right now I can’t try to put the scene as the main one, since the main is setting up various stuff for the game.
I have no image effects on my camera.
I honestly have no idea what could cause this - did you try removing stuff from your scene to find the culprit?
I have tried, yes.
By the way, the question is: does the internal function (the one which changes the scene) block the execution?
If yes, is there an easy way to avoid that?
Any luck? How much of the scene did you manage to delete?
I don’t quite understand the question. Application.LoadLevel is blocking. Application.LoadLevelAsync is not. Either way, the loading is done in a separate thread, just in the first case, the API blocks until the new scene is ready.
no lucks
I know the LoadLevelAsync is not blocking, but the problem is when the load is done and internally Unity3D makes the switch.
Could you be more explicit about it? What problem are you talking about?