- 最后登录
- 2019-12-2
- 注册时间
- 2012-8-25
- 阅读权限
- 90
- 积分
- 34660
- 纳金币
- 38268
- 精华
- 111
|
- using UnityEngine;
- using System.Collections;
- public class loadingscene : MonoBehaviour {
- int displayProgress = 0;
- // Use this for initialization
- void Start () {
- StartCoroutine("StartLoading");
- }
-
- private IEnumerator StartLoading()
- {
- int toProgress = 0;
- AsyncOperation op = Application.LoadLevelAsync(1);
- op.allowSceneActivation = false;
- while (op.progress < 0.9f)
- {
- toProgress = (int)op.progress * 100;
- while (displayProgress < toProgress)
- {
- ++displayProgress;
-
- yield return new WaitForEndOfFrame();
- }
- }
- toProgress = 100;
- while (displayProgress < toProgress)
- {
- ++displayProgress;
- yield return new WaitForEndOfFrame();
- }
- op.allowSceneActivation = true;
- }
- void OnGUI()
- {
- GUI.Label(new Rect(100, 100, 200, 100), "目前的进度"+displayProgress.ToString()+"%");
- }
- }
复制代码 |
|