示例#1
0
        private LoadOperation LoadLevelInternal <TParam>(string varBundleName, string varLevelName, LoadSceneMode varLoadSceneMode, LoadAssetCallback varCallBack, TParam varBackParam)
        {
            LoadOperation tempOperation = AnalysisEnvLevelOperation(varBundleName, varLevelName, varLoadSceneMode, varCallBack);

            tempOperation.CallbackParam = new ResourceLoadParam <TParam>(varBundleName, varLevelName, varBackParam);
            //是否需要新建一个队列;
            WaitingOperations.Insert(0, tempOperation);
            AutoPrepareEnv();
            return(tempOperation);
        }
示例#2
0
        private LoadOperation LoadAssetInternal <TAssetType, TParam>(string varBundleName, string varAssetName, bool varPriority, LoadAssetCallback <TAssetType> varCallBack, TParam varBackParam) where TAssetType : UnityEngine.Object
        {
            LoadOperation tempOperation = AnalysisEnvAssetOperation <TAssetType>(varBundleName, varAssetName, varCallBack);

            tempOperation.CallbackParam = new ResourceLoadParam <TParam>(varBundleName, varAssetName, varBackParam);

            if (varPriority)
            {
                AdvancedOperations.Add(tempOperation);
            }
            else
            {
                WaitingOperations.Add(tempOperation);
            }
            AutoPrepareEnv();
            return(tempOperation);
        }
示例#3
0
        /// <summary>
        /// 将自定义加载操作压入加载队列;
        /// </summary>
        /// <param name="varLoadOperation">自定义加载操作</param>
        /// <param name="varPriority">是否进入优先队列</param>
        /// <returns></returns>
        public LoadOperation PushCustomOperationInProcess(LoadOperation varLoadOperation, bool varPriority)
        {
            if (varLoadOperation == null)
            {
                Debug.LogError("ResourceManager.cs PushOperationInProcess ,Want In Process Operation is NULL.");
                return(varLoadOperation);
            }

            if (varPriority)
            {
                AdvancedOperations.Add(varLoadOperation);
            }
            else
            {
                WaitingOperations.Add(varLoadOperation);
            }
            AutoPrepareEnv();
            return(varLoadOperation);
        }
示例#4
0
        private IEnumerator LoadLooper()
        {
            while (true)
            {
                if (AdvancedOperations.Count > 0)
                {
                    mEmptyRunTimes = 0;
                    for (int i = 0; i < AdvancedOperations.Count; i++)
                    {
                        LoadOperation tempOper = AdvancedOperations[0];
#if LogFlag
                        DateTime tempBegin = DateTime.Now;
                        Debug.Log(string.Format("ResourceManager.cs Looper yield return new coroutine [{0}.{1}] .",
                                                tempOper.CallbackParam.AssetBundleName, tempOper.CallbackParam.AssetName));
#endif
                        if (false == tempOper.Execute())
                        {
                            yield return(mGameService.StartCoroutine(tempOper));
                        }
#if LogFlag
                        Debug.Log(string.Format("ResourceManager.cs Looper success [{0}.{1}] Cost second : {2}ms."
                                                , tempOper.CallbackParam.AssetBundleName, tempOper.CallbackParam.AssetName
                                                , DateTime.Now.Subtract(tempBegin).TotalMilliseconds));
#endif
                        try
                        {
                            tempOper.Finish();
                        }
                        catch (Exception e)
                        {
#if LogFlag
                            string tempError = string.Format("ResourceManager.cs Looper success,but some exception occuried. LoadOperation : [{0}],Asset : [{1}|{2}] \n Exception : {3} \n StackTrace : {4}",
                                                             tempOper, tempOper.CallbackParam.AssetBundleName, tempOper.CallbackParam.AssetName, e.Message, e.StackTrace);
                            Debug.LogError(tempError);
#endif
                        }
                        AdvancedOperations.RemoveAt(0);
                        i--;
                    }
                }
                if (WaitingOperations.Count > 0)
                {
                    mEmptyRunTimes = 0;
                    LoadOperation tempOper = WaitingOperations[0];
#if LogFlag
                    DateTime tempBegin = DateTime.Now;
                    Debug.Log(string.Format("ResourceManager.cs Looper yield return new coroutine [{0}.{1}] .",
                                            tempOper.CallbackParam.AssetBundleName, tempOper.CallbackParam.AssetName));
#endif
                    if (false == tempOper.Execute())
                    {
                        yield return(mGameService.StartCoroutine(tempOper));
                    }
#if LogFlag
                    Debug.Log(string.Format("ResourceManager.cs Looper success [{0}.{1}] Cost second : {2}ms."
                                            , tempOper.CallbackParam.AssetBundleName, tempOper.CallbackParam.AssetName
                                            , DateTime.Now.Subtract(tempBegin).TotalMilliseconds));
#endif
                    try
                    {
                        tempOper.Finish();
                    }
                    catch (Exception e)
                    {
#if LogFlag
                        string tempError = string.Format("ResourceManager.cs Looper success,but some exception occuried. LoadOperation : [{0}],Asset : [{1}|{2}] \n Exception : {3} \n StackTrace : {4}",
                                                         tempOper, tempOper.CallbackParam.AssetBundleName, tempOper.CallbackParam.AssetName, e.Message, e.StackTrace);
                        Debug.LogError(tempError);
#endif
                    }
                    WaitingOperations.RemoveAt(0);
                }

                mEmptyRunTimes++;
#if EditorVersion
                ShowWaitOpertionNum();
#endif
                if (mEmptyRunTimes >= ResConfig.EmptyRunLimit)
                {
                    yield break;
                }
                yield return(null);
            }
        }
示例#5
0
 /// <summary>
 /// 将自定义加载操作压入加载队列;
 /// </summary>
 /// <param name="varLoadOperation">自定义加载操作</param>
 /// <returns></returns>
 public LoadOperation PushCustomOperationInProcess(LoadOperation varLoadOperation)
 {
     return(PushCustomOperationInProcess(varLoadOperation, false));
 }