Exemplo n.º 1
0
        //public void Init()
        //{
        //    ResourceLoadParam param = new ResourceLoadParam();
        //    string fileName = Helper.GetFileNameFromFullPath(GAMEOBJPOOL_CONFIG_FILEPATH);
        //    param.keyID = GAMEOBJPOOL_CONFIG_FILEPATH;
        //    param.name = fileName;
        //    ResourceManager.GetSingleton().LoadAssetBundle(GAMEOBJPOOL_CONFIG_FILEPATH, fileName, typeof(TextAsset), OnLoadConfigCallback, param);
        //}

        /// <summary>
        /// 加载/获得 某个对象物体
        /// </summary>
        /// <param name="varTask"></param>
        public void LoadObj(LoadTask varTask)
        {
            if (varTask == null)
            {
                Helper.LogError("GameObjPool LoadObj:Error caused by null LoadTask instance");
                return;
            }
            if (varTask.mType == typeof(Texture) || varTask.mType == typeof(Texture2D) || varTask.mType == typeof(Texture3D))
            {
                varTask.mObjFlag = ObjFlag.UseOriObj;
            }
            if (string.IsNullOrEmpty(varTask.mFilePath))
            {
                Helper.LogError("GameObjPool LoadObj:Error caused by null LoadTask.mFilePath");
                return;
            }
            if (IsExistObjInfo(varTask.mFilePath))
            {
                varTask.Callback(GetCacheObjInfo(varTask.mFilePath, varTask.mObjFlag));
            }
            else
            {
                if (IsInLoading(varTask.mFilePath) == false)
                {
                    TaskQueue queue = new TaskQueue(varTask.mFilePath, varTask);
                    AddTaskQueue(queue);
                    queue.Excute();
                }
                else
                {
                    AddLoadTaskToQueue(varTask);
                }
            }
        }