using System.Collections;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class WSceneLoadAysc : MonoBehaviour
{
private Slider LoadingSlider;
private Text LoadText;
private float AsyncLoadVaule;
private AsyncOperation async = null;
void Start()
{
LoadText = transform.Find("LoadTip").GetComponent<Text>();
LoadingSlider = transform.Find("LoadValue").GetComponent<Slider>();
async = SceneManager.LoadSceneAsync("SeaIslandScene");
async.allowSceneActivation = false;
StartCoroutine(AsyncLoad());
}
IEnumerator AsyncLoad()
{
while (!async.isDone)
{
if (async.progress < 0.9f)
{
AsyncLoadVaule = async.progress;
}
else
{
AsyncLoadVaule = 1.0f;
}
LoadingSlider.value = AsyncLoadVaule;
LoadText.text = (int)(LoadingSlider.value * 100) + "%";
if (AsyncLoadVaule >= 0.9)
{
async.allowSceneActivation = true;
yield break;
}
}
}
}