IEnumerator Load() { AsyncOperation async = SceneManager.LoadSceneAsync(1); while (!async.isDone) { percentage = Mathf.Floor((async.progress * 100) / 0.9f); loadUI.UpdateUI(); yield return(null); } }
IEnumerator load(int sceneIndex) { //Create a variable that loads the scene AsyncOperation async = SceneManager.LoadSceneAsync(sceneIndex); //while loading is not done... while (!async.isDone) { //the progress will be between 0 and 0.9 so we will calculate it to be between 0 and 100 percentage = Mathf.Floor(async.progress / 0.9f); //Update the UI in the UIscript loadUI.UpdateUI(); //yield return something (Because the IEnumerator requires that) yield return(null); } }