• 场景切换 异步加载 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;
         }

  • 相关阅读:
    主机访问虚拟机ORACLE报错:ORA-12541: TNS:no listener解决办法&无法启动oracle listener服务解决办法
    C—杨辉三角
    C—水仙花数
    C—数组的转置
    C—完数
    C—判断素数
    C—斐波那契数列[生兔子问题]
    C—9*9乘法表
    eclipse常用快捷键(windows下)
    inline-block和text-indent在IE6,IE7下同时使用的兼容问题解决方法
  • 原文地址:https://www.cnblogs.com/softimagewht/p/4296371.html
Copyright © 2020-2023  润新知