loading通用界面笔记

Private Action proCB = null;

public void AsyncLoadScene(string sceneName, Action loaded)

    {

        loadingWnd.SetWndState();

        AsyncOperation sceneAsync = SceneManager.LoadSceneAsync(sceneName);

        prgCB = () =>

        {

            float val = sceneAsync.progress;

            loadingWnd.SetProgress(val);

            if (val == 1)

            {

                if (loaded != null)

                {

                    loaded();

                }

                prgCB = null;

                sceneAsync = null;

                loadingWnd.SetWndState(false);

            }

        };

}

void Update()

    {

        if (prgCB != null)

        {

            prgCB();

        }

    }

String sceneName;

AsyncLoadScene(sceneName,()=>{

//新场景加载成功后执行,初始化新场景

});

原文地址:https://www.cnblogs.com/tqvdong/p/14921649.html