找回密码
 立即注册
查看: 3912|回复: 86

[脚本] nity 利用协同程序实现场景切换时加载进度的监控 【转】

[复制链接]
发表于 2012-11-28 08:44 | 显示全部楼层 |阅读模式

  1. using UnityEngine;
  2. using System.Collections;

  3. public class FightTriggle : MonoBehaviour {
  4.     private AsyncOperation async;
  5.     int i = 0;
  6.     void OnTriggerEnter(Collider other)
  7.     {
  8.         Debug.Log("打开");
  9.         if (other.collider.gameObject.tag == "Player")
  10.         {
  11.             //打开副本UI
  12.             Debug.Log("打开副本");
  13.             StartCoroutine(GetProgress());

  14.         }

  15.     }
  16.     IEnumerator GetProgress()
  17.     {
  18.         async = Application.LoadLevelAsync(0);
  19.         yield return async;
  20.     }
  21.     void Update()
  22.     {
  23.         if (async != null)
  24.         {
  25.             if (!async.isDone)
  26.             {
  27.                 float progress = async.progress;
  28.                 Debug.Log("加载进度  " + async.progress);
  29.                 i++;
  30.                 Debug.Log("" + i+async.progress);
  31.             }
  32.         }

  33.     }
  34.     void OnTriggerExit(Collider other)
  35.     {
  36.         if (other.collider.gameObject.tag == "Player")
  37.         {
  38.             Debug.Log("关才副本");
  39.         }
  40.     }
  41. }
复制代码
发表于 2013-7-5 16:02 | 显示全部楼层
表示不好用
发表于 2017-2-24 16:26 | 显示全部楼层
楼主是超人
发表于 2017-2-24 16:20 | 显示全部楼层
真心顶
发表于 2017-2-24 16:30 | 显示全部楼层
难得一见的好帖
发表于 2017-2-24 16:47 | 显示全部楼层
说的非常好
发表于 2017-2-24 15:59 | 显示全部楼层
LZ真是人才
发表于 2017-4-28 20:19 | 显示全部楼层
楼主是超人
发表于 2017-4-28 20:22 | 显示全部楼层
说的非常好
发表于 2017-4-28 20:48 | 显示全部楼层
很好哦
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Unity开发者联盟 ( 粤ICP备20003399号 )

GMT+8, 2024-5-10 05:57 , Processed in 0.410288 second(s), 26 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表