zoukankan      html  css  js  c++  java
  • 场景切换 异步加载 loading条做法

     AsyncOperation mAsync; //需要加载的场景
        public UISlider LoadingSlider; //NGUI做的
        public UILabel GameTip;

         // Use this for initialization
         void OnEnable()
         {
             StartCoroutine("LoadScene");

             GameTip.text = GameTipsController.Singleton.RandomTip();
         }

         void OnDisable()
         {
             StopAllCoroutines();
         }


         // Update is called once per frame
         void Update()
         {
         }

         IEnumerator LoadScene()
         {
             int displayProgress = 0;
             int toProgress = 0;
             mAsync = Application.LoadLevelAsync(StaticDataCache.Singleton.CurLoadScene);
             mAsync.allowSceneActivation = false;
             Debug.Log(mAsync.progress);
             while (mAsync.progress < 0.9f)
             {
                 toProgress = (int)mAsync.progress * 100;
                 while (displayProgress < toProgress)
                 {
                     ++displayProgress;
                     SetLoadingSlider(displayProgress);
                     yield return new WaitForEndOfFrame() ;
                 }
                 yield return new WaitForEndOfFrame();
             }

             toProgress = 100;
             while (displayProgress < toProgress)
             {
                 ++displayProgress;
                 SetLoadingSlider(displayProgress);
                 yield return new WaitForEndOfFrame();
             }
             mAsync.allowSceneActivation = true;
             gameObject.SetActive(false);

         }

         void SetLoadingSlider(int progress)
         {
             float tmp = (float)((float)progress / 100);
             LoadingSlider.value = tmp;
         }

  • 相关阅读:
    C#生成安装文件后自动附加数据库的思路跟算法
    c#压缩和解压缩文件
    如何远程备份sql server数据库
    计算一年中的第几周/c#得到阳历对应农历日期
    C·处理数据库备份
    字符串提取替换后再替换回去 和 函数将数字转换中文数字
    Visual C#的Excel编程
    数据库备份和恢复
    blog
    请问谁知道DOTMSN中打开聊天对话框的方法是什么?
  • 原文地址:https://www.cnblogs.com/softimagewht/p/4296371.html
Copyright © 2011-2022 走看看