public void FinishedHandlerCallback(bool manual, TaskBase currentTask) { _listAssetsPathComplete.Add(currentTask._taskName); if (_listTaskItem.Count == _listAssetsPathComplete.Count) { stop(); finishExec(); } }
public void CreateFinishedHandler(bool manual, TaskBase currentTask) { finishExec(); _bCreating = false; _bCompelete = true; //刷新shader UnityEngine.SceneManagement.Scene newScene = SceneManager.GetSceneByName(currentTask._taskName); GameObject[] roots = newScene.GetRootGameObjects(); for (int i = 0; i < roots.Length; i++) { UtilTools.UpdateShaders(roots[i]); } }
public bool IsCurLoadingAssetPath(ref TaskBase except_task, string sAssetPath) { if (sAssetPath.Length == 0) { return(false); } //先从任务列表中找 for (int i = 0; i < _listTaskItem.Count; i++) { if (except_task != _listTaskItem[i] && _listTaskItem[i]._taskName == sAssetPath && !_listTaskItem[i].IsLoadComplete()) { return(_listTaskItem[i].IsLoading()); } } return(false); }
/// <summary> /// 任务停止执行回调处理 /// </summary> /// <param name="bManual">是否手动停止</param> /// <param name="task">停止的任务</param> public void taskFinishHandler(bool bManual, TaskBase task) { //Utils.LogSys.Log("Task complete: " + task._taskName); if (_listRuningTasks.Contains(task)) { _listRuningTasks.Remove(task); } if (_listWaitingTasks.Count > 0) { TaskBase t = _listWaitingTasks[0]; _listWaitingTasks.RemoveAt(0); //添加到运行列表 _listRuningTasks.Add(t); StartCoroutine(t.coroutineWrapper()); } }
/////////////////////////////////////////////////////////////////////////// /// <summary> /// 开始任务 /// </summary> /// <param name="task">任务对象</param> public void startTask(TaskBase task) { if (task == null) { return; } task.EventFinished += taskFinishHandler; if (_listRuningTasks.Count < MAX_CONCURRENCY_TASK) { _listRuningTasks.Add(task); StartCoroutine(task.coroutineWrapper()); } else { _listWaitingTasks.Add(task); } // for (int i=0; i<_listRuningTasks.Count; i++) // Utils.LogSys.Log ("------------>Runing Task:"+_listRuningTasks[i]._taskName); }
public void LoadFinishedHandler(bool manual, TaskBase currentTask) { _listAssetsPathComplete.Add(currentTask._taskName); if (_listTaskItem.Count == _listAssetsPathComplete.Count) { _bDownLoading = false; _bCreating = true; _create_task = new SceneAssetBundleCreateTask(_sSceneName, _bAdditive); _create_task.EventFinished += CreateFinishedHandler; if (_bCanShow) { _create_task.ToShowScene(); } /* * AssetBundle bundle = _listTaskItem[1].getTargetAssetbundle();//如果有lightmap.exr * if (bundle != null) * { * Object[] objects = bundle.LoadAllAssets<Object>(); * List<LightmapData> lmdList = new List<LightmapData>(); * foreach (Object obj in objects) * { * if (obj.GetType() == typeof(Texture2D)) * { * if (obj.name.Contains("Lightmap-") && obj.name.Contains("_comp_light")) * { * LightmapData lmd = new LightmapData(); * Texture2D tex = obj as Texture2D; * lmd.lightmapFar = tex; * lmdList.Add(lmd); * } * } * } * LightmapSettings.lightmaps = lmdList.ToArray(); * } * */ } }
///////////////////////////////////////////////////////////////////////// /// <summary> /// 兼容旧的单一task /// </summary> public TaskQueue(TaskBase tb, bool bAutoStart = true) : base(bAutoStart) { _queue.Add(tb); }