- Home /
Question by
Joseguepardo · Sep 10, 2016 at 08:47 AM ·
androidmobileloadlevelasyncopeningmobilephone
SceneManager.LoadSceneAsync loaded scene takes too long to open
I'm trying to make sort of a progression bar of a scene I'm loading in the background and that when it's fully loaded open it. The moment the bar reaches 100% it opens the scene. The problem is that when it reaches 100% and starts opening it, it takes too long to actually open (like 5 - 7 seconds after it has fully loaded). The application is for android, I've tested it on the newest phones and it's the same. Here is the code I'm using:
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using System.Collections;
public class MenuApp : MonoBehaviour {
AsyncOperation ao;
public GameObject loadingObject;
public Image loadingImg;
public Text loadingText;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public void LoadARScene(){
loadingObject.SetActive (true);
StartCoroutine (LoadARSceneInBG ());
}
IEnumerator LoadARSceneInBG(){
yield return new WaitForSeconds (1);
ao = SceneManager.LoadSceneAsync (1);
ao.allowSceneActivation = false;
while (!ao.isDone) {
loadingImg.fillAmount = ao.progress;
loadingText.text = (ao.progress * 100).ToString("F1") + "%";
if (ao.progress == 0.9f) {
loadingImg.fillAmount = 1;
loadingText.text = "100%";
ao.allowSceneActivation = true;
}
yield return null;
}
}
}
Maybe someone can help me with this issue??? Thanks...
Comment