hejianchun1314 发表于 2012-11-28 08:44

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


using UnityEngine;
using System.Collections;

public class FightTriggle : MonoBehaviour {
    private AsyncOperation async;
    int i = 0;
    void OnTriggerEnter(Collider other)
    {
      Debug.Log("打开");
      if (other.collider.gameObject.tag == "Player")
      {
            //打开副本UI
            Debug.Log("打开副本");
            StartCoroutine(GetProgress());

      }

    }
    IEnumerator GetProgress()
    {
      async = Application.LoadLevelAsync(0);
      yield return async;
    }
    void Update()
    {
      if (async != null)
      {
            if (!async.isDone)
            {
                float progress = async.progress;
                Debug.Log("加载进度" + async.progress);
                i++;
                Debug.Log("" + i+async.progress);
            }
      }

    }
    void OnTriggerExit(Collider other)
    {
      if (other.collider.gameObject.tag == "Player")
      {
            Debug.Log("关才副本");
      }
    }
}

jlzz147258 发表于 2013-7-5 16:02

表示不好用

tangyu3 发表于 2017-2-24 16:26

楼主是超人

kolanglang 发表于 2017-2-24 16:20

真心顶

zjxxgc1 发表于 2017-2-24 16:30

难得一见的好帖

wppqqwwsang 发表于 2017-2-24 16:47

说的非常好

ztdizi 发表于 2017-2-24 15:59

LZ真是人才

奔跑的蜗牛 发表于 2017-4-28 20:19

楼主是超人

小酷科技 发表于 2017-4-28 20:22

说的非常好

○2 发表于 2017-4-28 20:48

很好哦
页: [1]
查看完整版本: nity 利用协同程序实现场景切换时加载进度的监控 【转】