unity 过度条场景

来源:互联网 发布:除了淘宝 蓝光哪里买 编辑:程序博客网 时间:2024/06/04 18:00
using UnityEngine;
using UnityEngine.UI;


/// <summary>
/// UGUISceneLoader script.
/// This is used to show the progress of scene loading.
/// </summary>
public class UGUISceneLoader : MonoBehaviour
{
public Slider progressBar;
public Text progressText;

private AsyncOperation _async;

void Start()
{
// Scene Load asynchronously.
_async = Application.LoadLevelAsync(SceneManager.Instance.currentLoadScene);
Debug.Log (SceneManager.Instance.currentLoadScene);
}

void Update()
{
// Scene loading process update.
if (!_async.isDone)
{
float pProgress = _async.progress * 100f;
int pInt = Mathf.RoundToInt(pProgress);
progressText.text = pInt.ToString() + "%";
progressBar.value = _async.progress;
}
}
}
0 0
原创粉丝点击