Пример #1
0
        /// <summary>
        /// 加载场景
        /// </summary>
        /// <param name="abName"></param>
        /// <param name="sceneName"></param>
        /// <param name="onComplete"></param>
        /// <param name="onEnd"></param>
        /// <param name="allowSceneActivation"></param>
        /// <param name="loadSceneMode"></param>
        /// <returns></returns>
        static public void LoadScene(string abName, string sceneName, System.Action <object, object> onComplete, System.Action <object, object> onEnd, object userData = null, bool allowSceneActivation = true, LoadSceneMode loadSceneMode = LoadSceneMode.Additive)
        {
            var req = CRequest.Get();

            req.assetName       = sceneName;
            req.assetType       = LoaderType.Typeof_ABScene;
            req.assetBundleName = abName;
            req.OnComplete      = onComplete;
            req.OnEnd           = onEnd;
            req.userData        = userData;

            AsyncOperation request = null;

            if ((request = CacheManager.GetLoadingScene(sceneName)) != null)
            {
                request.allowSceneActivation = allowSceneActivation; //开始激活
                UnityEngine.Events.UnityAction <Scene, LoadSceneMode> onSceneLoaded = null;
                onSceneLoaded = (scene, model) =>
                {
                    SceneManager.sceneLoaded -= onSceneLoaded;
                    CacheManager.RemoveLoadingScene(req.assetName);
                    DispatchReqAssetOperation(req, false, 0, true);
                    CheckAllComplete();
                };

                SceneManager.sceneLoaded += onSceneLoaded;
            }
            else
            {
                LoadSceneAsset(req, allowSceneActivation, loadSceneMode);
            }
        }
Пример #2
0
        private static IEnumerator LoadDeActiveScene(AsyncOperation request, CRequest req, bool allowSceneActivation)
        {
            request.allowSceneActivation = allowSceneActivation;
            yield return(request.isDone);

            CacheManager.RemoveLoadingScene(req.assetName);
            DispatchReqAssetOperation(req, false, 0, true);
        }