Example #1
0
    IEnumerator StartLoading(string sceneName, OnAsyncLoadUIFinish finishCallBack, UIPanelType panelType = UIPanelType.None, params object[] paramList)
    {
        BasePanel      panel           = UIManager.Instance.PushPanel(UIPanelType.AsyncLoadingPanel);
        int            displayProgress = 0;
        int            toProgress      = 0;
        AsyncOperation op = SceneManager.LoadSceneAsync(sceneName);

        op.allowSceneActivation = false;
        while (op.progress < 0.9f)
        {
            toProgress = (int)op.progress * 100;
            while (displayProgress < toProgress)
            {
                ++displayProgress;
                SetLoadingPercentage(panel, displayProgress);
                yield return(new WaitForEndOfFrame());
            }
        }

        toProgress = 100;
        while (displayProgress < toProgress)
        {
            ++displayProgress;
            SetLoadingPercentage(panel, displayProgress);
            yield return(new WaitForEndOfFrame());
        }
        op.allowSceneActivation = true;
        UIManager.Instance.PopPanel();

        BasePanel basePanel = null;

        if (panelType != UIPanelType.None)
        {
            basePanel = UIManager.Instance.PushPanel(panelType, paramList: paramList);
        }
        ClearCache();
        finishCallBack?.Invoke(basePanel);
    }