异步加载
来源:互联网 发布:南通大学网络 编辑:程序博客网 时间:2024/05/19 19:59
using UnityEngine;using System.Collections;using UnityEngine.UI;using UnityEngine.SceneManagement;public class Loading : MonoBehaviour{ public Slider processBar; private AsyncOperation async; private int nowProcess; public Text _text; void Start() { StartCoroutine(loadScene()); } /// <summary> /// 加载完场景后就会跳转 /// </summary> /// <returns></returns> IEnumerator loadScene() { async = SceneManager.LoadSceneAsync("123"); async.allowSceneActivation = false; yield return new WaitForEndOfFrame(); } void Update() { if (async == null) { return; } int toProcess; // async.progress 你正在读取的场景的进度值 0---0.9 // 如果当前的进度小于0.9,说明它还没有加载完成,就说明进度条还需要移动 // 如果,场景的数据加载完毕,async.progress 的值就会等于0.9 if (async.progress < 0.9f) { toProcess = (int)async.progress * 100; } else { toProcess = 100; } // 如果滑动条的当前进度,小于,当前加载场景的方法返回的进度 if (nowProcess < toProcess) { nowProcess++; } processBar.value = nowProcess / 100f; _text.text = nowProcess.ToString() + "%"; // 设置为true的时候,如果场景数据加载完毕,就可以自动跳转场景 if (nowProcess == 100) { async.allowSceneActivation = true; } }}
个人学习收藏,不做他用
阅读全文
0 0
- 异步加载
- 异步加载
- 异步加载
- 异步加载
- 异步加载
- 异步加载
- 异步加载
- *【异步加载】
- 异步加载
- 异步加载
- 异步加载
- 异步加载
- 异步加载
- 异步加载
- 异步加载
- 异步加载
- 异步缓存,异步加载
- 页面同步加载&&异步加载
- Java新增修改保存在数据库乱码问题
- C#as关键字
- 3.C++进化后的 const
- jquery validate
- Word表格外的第一个空行如何删除
- 异步加载
- C语言初步-第47讲: 小小型应用系统开发指导(模拟银行储蓄系统的基本功能)
- Failed to resolve: com.android.support.constraint:constraint-layout
- java中循环引用会不会防止GC回收
- byte解析为bool
- OutOfMemoryError系列(7): Requested array size exceeds VM limit
- C_十进制,二进制,八进制,十六进制
- JavaScript学习笔记
- Android 6.0 沉浸式状态栏