Beispiel #1
0
        /// <summary>
        /// 加载错误的事件监听
        /// </summary>
        /// <param name="gEvent">G event.</param>
        private void onLoadErrorHandler(BaseLoader.LoadVo loadVo, object param)
        {
            currentLoadingNumber -= 1;

            LoadIngInfo loadingInfo = cachesLoadIngs[loadVo.currentLoader.NavitePath];

            loadVo.dataFormat = loadingInfo.dataFormate;

            //遍历失败回调方法
            BaseLoader.OnLoadError completeHandler;
            for (int index = 0; index < loadingInfo.onLoadError.Count; index++)
            {
                completeHandler = (BaseLoader.OnLoadError)loadingInfo.onLoadError[index];

                if (completeHandler == null)
                {
                    continue;
                }

                if (isInMapEditor == true)
                {
                    completeHandler.Invoke(loadVo, loadingInfo.onErrorArgs [index]);
                }
                else
                {
                    StartCoroutine(DispatchError(completeHandler, loadVo, loadingInfo.onErrorArgs [index]));
                }
            }

            destroyLoader(loadVo.currentLoader);
            cachesLoadIngs.Remove(loadingInfo.assetPath);

            loadByQueue();
        }
Beispiel #2
0
        /// <summary>
        /// 删除缓存
        /// </summary>
        /// <param name="key">Key.</param>
        public void remove(string key)
        {
            if (key == null)
            {
                return;
            }

            ///对于重复key值的信息,不缓存
            if (cacheLoadVos.ContainsKey(key) == false)
            {
                return;
            }


            BaseLoader.LoadVo loadVo = cacheLoadVos[key];
            if (loadVo == null)
            {
                return;
            }

            //引用记数减1
            loadVo.referenceCout -= 1;
            if (loadVo.referenceCout > 0)
            {
                return;
            }
            cacheLoadVos.Remove(key);
            loadVo.Dispose();
        }
Beispiel #3
0
        /// <summary>
        /// 加载完成后的事件监听
        /// </summary>
        /// <param name="gEvent">G event.</param>
        private void onLoadCompleteHandler(BaseLoader.LoadVo loadVo, object param)
        {
            currentLoadingNumber -= 1;
            LoadIngInfo loadingInfo = cachesLoadIngs[loadVo.currentLoader.NavitePath];

            loadVo.dataFormat = loadingInfo.dataFormate;

            //遍历成功回调方法
            BaseLoader.OnLoadComplete completeHandler;
            for (int index = 0; index < loadingInfo.onComplete.Count; index++)
            {
                completeHandler = (BaseLoader.OnLoadComplete)loadingInfo.onComplete[index];
                if (completeHandler == null)
                {
                    continue;
                }
                if (isInMapEditor == true)
                {
                    completeHandler.Invoke(loadVo, loadingInfo.onCompleteArgs [index]);
                }
                else
                {
                    StartCoroutine(DispatchSuccess(completeHandler, loadVo, loadingInfo.onCompleteArgs [index]));
                }
            }

            //缓存游戏加载对象
            CacheManager.Instance.cache(loadingInfo.assetPath, loadVo);

            destroyLoader(loadVo.currentLoader);
            cachesLoadIngs.Remove(loadingInfo.assetPath);

            loadByQueue();
        }
Beispiel #4
0
 /// <summary>
 /// 加载进度的回调函数
 /// </summary>
 /// <param name="loadVo">Load vo.</param>
 protected void invokeLoadProgress(BaseLoader.LoadVo loadVo)
 {
     if (_onLoadProgress == null)
     {
         return;
     }
     _onLoadProgress.Invoke(loadVo, null);
 }
Beispiel #5
0
 /// <summary>
 /// 加载成功后的回调函数
 /// </summary>
 /// <param name="loadVo">Load vo.</param>
 protected void invokeLoadComplete(BaseLoader.LoadVo loadVo)
 {
     if (_onLoadComplete == null)
     {
         return;
     }
     _onLoadComplete.Invoke(loadVo, null);
 }
Beispiel #6
0
 /// <summary>
 /// 加载失败后的回调函数
 /// </summary>
 /// <param name="loadVo">Load vo.</param>
 protected void invokeLoadError(BaseLoader.LoadVo loadVo)
 {
     if (_onLoadError == null)
     {
         return;
     }
     _onLoadError.Invoke(loadVo, null);
 }
Beispiel #7
0
        /// <summary>
        /// 加载各种资源,
        ///     包括prefab预制,只能是Resource路径下的资源,加载本地的Resources资源,路径前面不用/
        ///     audio声效,
        ///     assetsBundle本地资源和服务器资源,
        ///     ttf字体,
        ///     binary本地资源和网络资源
        /// </summary>
        /// <param name="assetPath">资源路径</param>
        /// <param name="dataFormat">数据格式,默认是assetbundle</param>
        /// <param name="onComplete">加载成功回调函数</param>
        /// <param name="loadComplemeArgs">回载成功后的回调函数参数</param>
        /// <param name="onLoadError">加载失败回调函数</param>
        /// <param name="loadErrorArgs">回载失败的回调函数参数</param>
        /// <param name="onLoadProgress">显示进度回调函数</param>
        /// <param name="loadProgressArgs">显示进度时的回调参数</param>
        public void loadAssets(string assetPath, string dataFormat = ASSETS_BUNDLE, BaseLoader.OnLoadComplete onComplete = null, object loadComplemeArgs = null, BaseLoader.OnLoadError onLoadError = null, object loadErrorArgs = null, BaseLoader.OnLoadProgress onLoadProgress = null, object loadProgressArgs = null)
        {
            this.isInMapEditor = false;
            //判断缓存中有没有资源,如果有就直接返回
            BaseLoader.LoadVo loadVo = CacheManager.Instance.getCacheLoadedObject(assetPath);
            if (loadVo != null)
            {
                StartCoroutine(DispatchSuccess(onComplete, loadVo, loadComplemeArgs));
                return;
            }

            this.doLoadAsset(assetPath, dataFormat, onComplete, loadComplemeArgs, onLoadError, loadErrorArgs, onLoadProgress, loadProgressArgs);
        }
Beispiel #8
0
        /// <summary>
        /// 缓存加载信息数据
        /// </summary>
        /// <param name="key">Key.</param>
        /// <param name="loadVo">Load vo.</param>
        public void cache(string key, BaseLoader.LoadVo loadVo)
        {
            if (key == null || loadVo == null)
            {
                return;
            }

            ///对于重复key值的信息,不缓存
            if (cacheLoadVos.ContainsKey(key) == true)
            {
                return;
            }
            cacheLoadVos.Add(key, loadVo);
        }
Beispiel #9
0
        /// <summary>
        /// 实例化缓存对象,
        /// </summary>
        /// <returns>生成具体对象</returns>
        /// <param name="key">获取key值</param>
        public BaseLoader.LoadVo getCacheLoadedObject(string key)
        {
            if (key == null)
            {
                return(null);
            }


            ///对于重复key值的信息,不缓存
            if (cacheLoadVos.ContainsKey(key) == false)
            {
                return(null);
            }

            BaseLoader.LoadVo loadVo = cacheLoadVos[key];

            return(loadVo);
        }
Beispiel #10
0
        IEnumerator DispatchError(BaseLoader.OnLoadError callBack, BaseLoader.LoadVo loadVo, object param)
        {
            yield return(1);

            callBack(loadVo, param);
        }
Beispiel #11
0
 /// <summary>
 /// 加载进度的事件监听
 /// </summary>
 /// <param name="gEvent">G event.</param>
 private void onLoadProgressHandler(BaseLoader.LoadVo loadVo, object param)
 {
 }
Beispiel #12
0
        IEnumerator DispatchSuccess(BaseLoader.OnLoadComplete callBack, BaseLoader.LoadVo loadVo, object param = null)
        {
            yield return(1);

            callBack(loadVo, param);
        }