Ejemplo n.º 1
0
    public void LoadNextScene(string sceneName, DelAfterLoadScene del = null)
    {
        if (willShowSceneName == sceneName)
        {
            return;
        }
        willShowSceneName = sceneName;
        theDel            = del;

        StartCoroutine(LoadScene(sceneName));

        GameTool.ClearMemory();
    }
Ejemplo n.º 2
0
    IEnumerator LoadScene(string sceneName)
    {
        asyn = SceneManager.LoadSceneAsync(sceneName);
        asyn.allowSceneActivation = false;
        yield return(asyn);

        if (asyn.isDone)
        {
            if (theDel != null)
            {
                theDel();
            }

            asyn = null;
            GameTool.ClearMemory();
        }
    }
Ejemplo n.º 3
0
 void Update()
 {
     if (asyn == null)
     {
         return;
     }
     // Debug.Log("*********************"+ asyn.allowSceneActivation);
     //asyn.progress范围0~1,但是要注意,这个值顶多检测到0.9
     if (asyn.progress < 0.9f)
     {
         //场景未加载完成
         theProgress = (int)asyn.progress * 100;
     }
     else
     {
         //加载完成
         theProgress = 100;
     }
     if (showProgress < theProgress)
     {
         showProgress++;
     }
     //Debug.Log("showProgress :"+ showProgress);
     //让进度条走动起来
     slider_Progress.value = showProgress / 100f;
     if (showProgress == 100) //&& asyn.isDone)
     {
         //场景加载完成,显示出来
         asyn.allowSceneActivation = true;
     }
     if (asyn.isDone)
     {
         if (LoadSceneManager.Instance.callBack != null)
         {
             LoadSceneManager.Instance.callBack();
         }
         asyn = null;
         slider_Progress.value = 0;
         showProgress          = 0;
         theProgress           = 0;
         GameTool.ClearMemory();
     }
 }