Example #1
0
    IEnumerator Load(string sceneName, LoadSceneMode mode, LoadSceneCallBack callback, bool isWait = true)
    {
        UIManager._Instance.OpenWindow(WindowName.LoadScene, UIType.Loading);
        AsyncOperation ao = SceneManager.LoadSceneAsync(sceneName, mode);

        ao.allowSceneActivation = false;
        float progress = 0f;

        while (!ao.isDone && progress < 1)           //是否加载完成
        //Debug.Log(ao.progress);
        {
            if (ao.progress < 0.9f)
            {
                progress = Mathf.Lerp(progress, ao.progress, Time.deltaTime);
            }
            else
            {
                progress = Mathf.Lerp(progress, 1.05f, Time.deltaTime);
            }
            if (loadingCallBack != null)
            {
                loadingCallBack(progress > 1 ? 1 : progress);
            }
            yield return(null);
        }
        ao.allowSceneActivation = true;
        yield return(null);

        if (callback != null)
        {
            callback();
        }
        loadingCallBack = null;
        if (isWait)
        {
            yield return(new WaitForSeconds(0.5f));
        }
        UIManager._Instance.CloseWindow(WindowName.LoadScene);
    }
Example #2
0
 public void LoadScene(SceneName sceneName, LoadSceneCallBack callback, bool isWait)
 {
     load.StartCoroutine(Load(sceneName.ToString(), LoadSceneMode.Single, callback, isWait));
 }
Example #3
0
 public void LoadScene(int sceneIndex, LoadSceneCallBack callback)
 {
     load.StartCoroutine(Load(((SceneName)sceneIndex).ToString(), LoadSceneMode.Single, callback));
 }
Example #4
0
 public void LoadScene(SceneName sceneName, LoadSceneMode mode, LoadSceneCallBack callback)
 {
     load.StartCoroutine(Load(sceneName.ToString(), mode, callback));
 }