using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class loadingBar : MonoBehaviour {
AsyncOperation ao;
public GameObject loadingScreenBG;
public GameObject loadingLogo;
public Image progBar;
public Text loadingText;
void Start()
{
StartCoroutine(loadmainScene());
StartCoroutine(LoadLevelwithRealProgress());
}
void Update()
{
}
IEnumerator loadmainScene()
{
loadingScreenBG.SetActive(true);
loadingLogo.SetActive(true);
yield return new WaitForSeconds(1);
progBar.gameObject.SetActive(true);
loadingText.gameObject.SetActive(true);
loadingText.text = "Loading. . .";
}
IEnumerator LoadLevelwithRealProgress()
{
yield return new WaitForSeconds(1);
ao = SceneManager.LoadSceneAsync(1);
ao.allowSceneActivation = true;
while(!ao.isDone)
{
progBar.fillAmount = ao.progress;
Debug.Log(ao.progress);
yield return null;
}
}
}