Question by
kosted · Dec 28, 2015 at 12:42 AM ·
strange iocprogress-barprogress
[Loading scence] async progress returns always return 0
I everybody, I'm making a loading scence using scene manager LoadScenceAsync. I would use the progress value to have an loading UI, but I have always 0. I found anywhere an answer. Do you know please, how could I do ?
here my code : using UnityEngine; using System.Collections; using UnityEngine.UI; using UnityEngine.SceneManagement;
public class LevelLoader : MonoBehaviour {
public GameObject LoadingScene;
public Image LoadingBar;
public Text textPourcentage; //The text with the percentage increasing
public void LoadLevel (string nomScene) //The name of the scene
{
StartCoroutine (LevelCoroutine (nomScene));
}
IEnumerator LevelCoroutine (System.String nomScene)
{
LoadingScene.SetActive (true);
AsyncOperation async = SceneManager.LoadSceneAsync(nomScene);
while (!async.isDone) {
LoadingBar.fillAmount = async.progress ; //Async progress returns always 0 here
Debug.Log(async.progress);
textPourcentage.text = LoadingBar.fillAmount + "%"; //I have always 0% because he fillAmount is always 0
yield return null;
}
}
}
Comment
Answer by mikeNspired · May 01, 2019 at 08:52 PM
You ever figure this out? The only way I get any time of % is by splitting my scenes up into chunks and loading a list of scenes as additive....