Ejemplo n.º 1
0
        /// <summary>
        /// 缓存加载数据
        /// </summary>
        public static bool cacheLoadInfo(Dictionary <string, QueueLoader.LoadIngInfo> cachesLoadIngs, string assetPath, string dataFormat = QueueLoader.ASSETS_BUNDLE, BaseLoader.OnLoadComplete onComplete = null, object loadComplemeArgs = null, BaseLoader.OnLoadError onLoadError = null, object loadErrorArgs = null, BaseLoader.OnLoadProgress onLoadProgress = null, object loadProgressArgs = null)
        {
            QueueLoader.LoadIngInfo loadingInfo = null;

            if (cachesLoadIngs.ContainsKey(assetPath) == false)
            {
                loadingInfo             = new QueueLoader.LoadIngInfo();
                loadingInfo.assetPath   = assetPath;
                loadingInfo.dataFormate = dataFormat;

                //回调方法
                loadingInfo.onLoadError    = new List <BaseLoader.OnLoadError>();
                loadingInfo.onComplete     = new List <BaseLoader.OnLoadComplete>();
                loadingInfo.onLoadProgress = new List <BaseLoader.OnLoadProgress>();

                //回调方法
                loadingInfo.onLoadError.Add(onLoadError);
                loadingInfo.onComplete.Add(onComplete);
                loadingInfo.onLoadProgress.Add(onLoadProgress);

                //回调参数dictionary
                loadingInfo.onErrorArgs    = new List <object>();
                loadingInfo.onCompleteArgs = new List <object>();
                loadingInfo.onProgressArgs = new List <object>();

                //当前的回调参数
                loadingInfo.onErrorArgs.Add(loadErrorArgs);
                loadingInfo.onCompleteArgs.Add(loadComplemeArgs);
                loadingInfo.onProgressArgs.Add(loadProgressArgs);

                cachesLoadIngs.Add(assetPath, loadingInfo);

                return(false);
            }
            else
            {
                loadingInfo = cachesLoadIngs [assetPath];;

                //当前的回调参数
                loadingInfo.onErrorArgs.Add(loadErrorArgs);
                loadingInfo.onCompleteArgs.Add(loadComplemeArgs);
                loadingInfo.onProgressArgs.Add(loadProgressArgs);

                //回调方法
                loadingInfo.onLoadError.Add(onLoadError);
                loadingInfo.onComplete.Add(onComplete);
                loadingInfo.onLoadProgress.Add(onLoadProgress);

                return(true);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 创建加载类
        /// </summary>
        /// <returns>The loader.</returns>
        /// <param name="loadIngInfo">Load ing info.</param>
        public static BaseLoader createLoader(QueueLoader.LoadIngInfo loadIngInfo, GameObject gameObject)
        {
            if (loadIngInfo == null || loadIngInfo.dataFormate == null)
            {
                return(null);
            }

            if (loadTypes.ContainsKey(loadIngInfo.dataFormate) == false)
            {
                return(null);
            }

            Type loaderType = loadTypes[loadIngInfo.dataFormate];

            if (loaderType == null)
            {
                return(null);
            }
            BaseLoader resultLoader = gameObject.AddComponent(loaderType) as BaseLoader;            //;Activator.CreateInstance (loaderType.GetType());

            return(resultLoader);
        }