Example #1
0
        /// <summary>
        /// 增加要加载的远程服务器资源
        /// </summary>
        /// <param name="url">资源url</param>
        /// <returns></returns>
        public AssetsLoader AddRemote(string url, string relativeName, bool toLower = false)
        {
            if (mLoader != default)
            {
                if (toLower)
                {
                    url          = url.ToLower();
                    relativeName = relativeName.ToLower();
                }
                else
                {
                }

                LoaderOpertion opertion = new LoaderOpertion()
                {
                    remoteURL    = url,
                    relativeName = relativeName,
                    isRemote     = true,
                };
                "log: 添加远端资源队列: {0}".Log(opertion.relativeName);

                AddResList(ref url, false);
                mOpertions.Enqueue(opertion);
            }
            else
            {
            }

            return(this);
        }
Example #2
0
        private void LoadDependeceItem(out int statu)
        {
            statu = 0;
            if ((mOpertions != default) && (mOpertions.Count > 0))
            {
                mCurrentOption = mOpertions.Dequeue();

                string source = mCurrentOption.relativeName;
                if (mCurrentOption.isGetDependencies)
                {
                    InitDependencesList(source);
                    mIndex = 0;
                    source = GetValidSourceByIndex(ref source);
                    mIndex++;
                }
                else if (!mCurrentOption.isManifest)
                {
                    source = mCurrentOption.url;
                }
                if (!string.IsNullOrEmpty(source))
                {
                    mLoader.Load(source);
                }
                else
                {
                    statu = 2;
                }
            }
Example #3
0
 public AssetsLoader AddRemote(string url)
 {
     if (mLoader != default)
     {
         LoaderOpertion opertion = new LoaderOpertion()
         {
             url = url
         };
         mOpertions.Enqueue(opertion);
     }
     return(this);
 }
Example #4
0
 public AssetsLoader Add(string relativeName, bool isDependenciesLoader = true)
 {
     if (mLoader != default)
     {
         LoaderOpertion opertion = new LoaderOpertion()
         {
             relativeName      = relativeName,
             isGetDependencies = isDependenciesLoader
         };
         mOpertions.Enqueue(opertion);
     }
     return(this);
 }
Example #5
0
 public AssetsLoader Add(string relativeName, string manifestName)
 {
     if (mLoader != default)
     {
         LoaderOpertion opertion = new LoaderOpertion()
         {
             manifestName = manifestName,
             relativeName = relativeName,
             isManifest   = true,
         };
         mOpertions.Enqueue(opertion);
     }
     return(this);
 }
Example #6
0
        /// <summary>
        /// 增加需要加载的本地资源
        /// </summary>
        /// <param name="relativeName">资源名,通常为资源相对路径中的一部分</param>
        /// <param name="isDependenciesLoader">是否加载依赖资源文件</param>
        /// <returns></returns>
        public AssetsLoader Add(string relativeName, bool isDependenciesLoader = true, bool isPersistent = false)
        {
            if (mLoader != default)
            {
                LoaderOpertion opertion = new LoaderOpertion()
                {
                    relativeName      = relativeName,
                    isGetDependencies = isDependenciesLoader,
                    isPersistentPath  = !IgnoreRemote && isPersistent,
                };
                InitDependencesList(ref opertion, isPersistent);
                "log: 添加本地资源队列: {0}".Log(opertion.relativeName);
                mOpertions.Enqueue(opertion);
            }
            else
            {
            }

            return(this);
        }
Example #7
0
        public AssetsLoader AddConfig(string relativeName, bool isPersistent = false)
        {
            if (mLoader != default)
            {
                LoaderOpertion opertion = new LoaderOpertion()
                {
                    relativeName     = relativeName,
                    isPersistentPath = isPersistent,
                    isConfig         = true,
                };
                "log: 添加配置资源队列: {0}".Log(opertion.relativeName);

                AddResList(ref relativeName, false);
                mOpertions.Enqueue(opertion);
            }
            else
            {
            }

            return(this);
        }
Example #8
0
        /// <summary>
        /// 增加需要加载本地资源的主依赖文件
        /// </summary>
        /// <param name="relativeName">资源名,通常为资源相对路径中的一部分</param>
        /// <param name="manifestName">总依赖名</param>
        /// <returns></returns>
        public AssetsLoader AddManifest(string manifestName, bool isPersistent = false)
        {
            if (mLoader != default)
            {
                LoaderOpertion opertion = new LoaderOpertion()
                {
                    manifestName     = manifestName,
                    relativeName     = manifestName,
                    isManifest       = true,
                    isPersistentPath = isPersistent,
                };
                "log: 添加资源主依赖队列: {0}".Log(opertion.relativeName);

                AddResList(ref manifestName, true);
                mOpertions.Enqueue(opertion);
            }
            else
            {
            }

            return(this);
        }
Example #9
0
        /// <summary>
        /// 加载资源依赖项
        /// </summary>
        /// <param name="statu">返回的处理状态,0=正常,1=操作器为空,2=没有依赖资源</param>
        private void StartLoad(out int statu)
        {
            statu          = 0;
            mCurrentOption = default;
            if ((mOpertions != default) && (mOpertions.Count > 0))
            {
                mCurrentOption = mOpertions.Dequeue();

                string source = mCurrentOption.relativeName;
                if (mCurrentOption.isGetDependencies)//资源依赖
                {
                    if (!mCurrentOption.hasWalkDependences)
                    {
                        InitDependencesList(ref mCurrentOption, mCurrentOption.isPersistentPath, false);//补充获取要加载的资源依赖文件
                    }
                    else
                    {
                    }
                    InitAssetLoader();
                    source = GetPathByLoaderOption(mCurrentOption, source);
                }
                else
                {
                    if (mCurrentOption.isRemote)
                    {
                        InitDefaultLoader();
                        source = mCurrentOption.remoteURL;
                    }
                    else if (mCurrentOption.isManifest)//资源主依赖
                    {
                        InitAssetLoader();
                        source = GetPathByLoaderOption(mCurrentOption, source);
                    }
                    else if (mCurrentOption.isConfig)
                    {
                        InitDefaultLoader();
                        source = GetPathByLoaderOption(mCurrentOption, source);
                    }
                    else
                    {
                        "error".Log("加载的操作项出错.");
                    }
                }

                if (string.IsNullOrEmpty(source))
                {
                    LoadNext(out statu);//若依赖资源的路径为空,加载下一个资源
                    "empty deps".Log(statu == 2);
                }
                else
                {
                    if (mCurrentOption.isRemote || mCurrentOption.isConfig)
                    {
                        InitDefaultLoader();
                    }
                    else
                    {
                        InitAssetLoader();
                    }

                    "load res".Log(source);
                    mLoader.Load(source);//加载当前资源的依赖资源
                }
            }