using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class Load : MonoBehaviour
{
public Text loadText;
private int progress = 0;
private AsyncOperation async;
// Start is called before the first frame update
void Start()
{
StartCoroutine(LoadScenes());
}
IEnumerator LoadScenes()
{
int nDisPlayProgress = 0;
async = SceneManager.LoadSceneAsync("Main");
async.allowSceneActivation = false;
while (async.progress < 0.9f)
{
progress = (int)async.progress * 100;
while (nDisPlayProgress < progress)
{
++nDisPlayProgress;
loadText.text = ((int)nDisPlayProgress).ToString() + "%";
yield return new WaitForEndOfFrame();
}
Debug.Log("loadText.text : " + loadText.text);
yield return null;
}
//async.allowSceneActivation = true;
progress = 100;
while (nDisPlayProgress < progress)
{
++nDisPlayProgress;
loadText.text = ((int)nDisPlayProgress).ToString() + "%";
yield return new WaitForEndOfFrame();
}
async.allowSceneActivation = true;
}
}