I have a problem when the program load scenes. Sometimes works and sometimes not.
I have this sequence
Scene1 —> Scene2 --async–> Scene3 —> Scene1 —> Scene2 --async–> Scene3
Sometimes the first LoadLevelAsync works fine and the second not.
Scene3 is the game, and it has an scenario, characters, a lot of stuff. When I back from that scene to scene1 and then on scene2 call LoadLevelAsync, always freezes. I dont know why, because, previously the first asyncload worked fine.
The code is this:
using UnityEngine;
using System.Collections;
public class LevelLoader : MonoBehaviour {
static public string LevelToLoad="Menu";
public AsyncOperation async = null;
private float progreso = 0.0f;
private bool ejecutado = false;
IEnumerator Start() {
async = Application.LoadLevelAsync(LevelToLoad);
async.allowSceneActivation = false;
yield return async;
}
void FixedUpdate () {
if (async != null){
progreso = async.progress;
transform.localScale = new Vector3(progreso, 1, 1);
if (progreso>=0.9f) {
transform.localScale = new Vector3(1, 1, 1);
if(!ejecutado){
ejecutado = true;
Invoke("LoadLevel",1f);
}
}
}
}
void LoadLevel(){
async.allowSceneActivation = true;
}
}
And the call to execute this script is this:
LevelLoader.LevelToLoad = "Menu";
Application.LoadLevel("LevelLoader");
Does anybody had problems with LoadLevelAsync on Android?
Regards and sorry, I have a better spanish