Unity3D异步加载
来源:互联网 发布:人工智能电影图片 编辑:程序博客网 时间:2024/06/03 14:59
在unity3D中除了简单的同步加载,代码如下
using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.SceneManagement;public class StartGame : MonoBehaviour{ public void BtnChanged() { SceneManager.LoadScene(0); }}
还有异步加载,主要是为了在Loading场景中展现进度条,使得切换场景中不枯燥,有一定的交互性
using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.UI;using UnityEngine.SceneManagement;public class LoadingScene : MonoBehaviour { public Image progressImg; public Text text; private AsyncOperation async; private int curProgressValue = 0;// Use this for initializationvoid Start () { StartCoroutine(LoadScene());}// Update is called once per framevoid Update () { if (async == null) { return; } int progressValue = 0; if (async.progress < 0.9f) { progressValue = (int)async.progress * 100; } else { progressValue = 100; } if (curProgressValue < progressValue) { curProgressValue++; } text.text = curProgressValue + "%"; progressImg.fillAmount = curProgressValue / 100f; if (curProgressValue == 100) { async.allowSceneActivation = true; }} IEnumerator LoadScene() { async = SceneManager.LoadSceneAsync(1); //加载到90%不会直接跳转 async.allowSceneActivation = false; yield return async; }}
阅读全文
0 0
- unity3d异步加载场景
- unity3d异步加载场景
- Unity3D异步加载方法
- unity3d异步加载场景
- unity3d,异步加载场景
- unity3d异步加载场景
- Unity3d异步加载进度条
- Unity3D异步加载
- Unity3D异步加载游戏场景
- 【Unity3d】浅谈异步加载场景
- Unity3D异步加载游戏场景
- unity3d 异步加载场景和游戏对象
- unity3d 异步加载关卡进度条显示
- unity3d实现Loading进度条异步加载场景
- Unity3d之异步加载的研究
- Unity3D场景异步加载的实现案例
- Unity3D 场景切换异步加载进度
- Unity3D研究院之异步加载游戏场景与异步加载游戏资源进度条
- 1008. Elevator (20)
- VScode编辑器 ~常用快捷键
- 三分法模板
- 嵌入式开发IO基础
- 2017阿里巴巴内推面经—测试开发岗
- Unity3D异步加载
- java访问Hbase
- redis学习及实践3---Jedis、JedisPool、Jedis分布式实例介绍
- Maven坐标和仓库
- TCP SYN洪泛攻击的原理及防御方法
- C语言的位运算的优势
- MySQL安装
- 简书再切换回csdn
- LaTeX论文图片排版