using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection.Emit;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class Material : MonoBehaviour
{
public Slider slider;//进度条
AsyncOperation a;//异步加载对象
float temp;
private void Start()
{
slider.value = 0;
StartCoroutine(Demo1());
}
private IEnumerator Demo1()
{
a= SceneManager.LoadSceneAsync(2);
a.allowSceneActivation = false;
yield return a;
}
private void Update()
{
if (a.progress >= 0.8)
{
temp = 1;
}
else
{
temp = a.progress;
}
slider.value = Mathf.Lerp(slider.value, temp, Time.deltaTime);
if (Mathf.RoundToInt(slider.value*100) ==100)
{
a.allowSceneActivation = true;
}
}
}
异步加载
最新推荐文章于 2018-07-19 13:02:57 发布