/// <summary> /// 本地加载,支持 texture,audio,txt,types,prefab /// </summary> /// <param name="resPath">路径需包含后缀名,本地载入会进行截取</param> /// <param name="loaderFileComplete"></param> /// <param name="loaderError"></param> /// <param name="param"></param> private static void LoadFromLocalRes <T>( StResPath resPath, string id, ResLoaderManager.DelegateListLoaded loaderListComplete, ResLoaderManager.DelegateFileLoaded loaderFileComplete, ResLoaderManager.DelegateLoaderError loaderError, ResLoaderManager.DelageteLoaderListProgress loaderListProgress = null, object param = null) where T : UnityEngine.Object { //完整路径 string fullPath = SystemConfig.localPlatformResPath + resPath.path + ".unity3d"; if (ResDataManager.instance.HasEditorRes(fullPath)) { if (loaderFileComplete != null) { loaderFileComplete(fullPath, param); } } else { VOLocalLoadNode node = new VOLocalLoadNode(); node.resPath = resPath; node.id = id; node.loaderListComplete = loaderListComplete; node.loaderFileComplete = loaderFileComplete; node.loaderError = loaderError; node.loaderListProgress = loaderListProgress; node.param = param; node.type = typeof(T).ToString(); StartLoad(node); } }
private static void StartLoad(VOLocalLoadNode node) { _listNode.Add(node); if (_listNode.Count == 1) { CoroutineDelegate.StartCoroutines(OnLocalLoadThread(node)); } }
private static IEnumerator OnLocalLoadThread(VOLocalLoadNode node) { while (_listNode.Count > 0) { UnityEngine.Object obj = Resources.Load(node.resPath.path); _listNode.Remove(node); //完整路径 if (node.resPath.path.IndexOf(".unity3d") == -1) { node.resPath.path = SystemConfig.localPlatformResPath + node.resPath.path + ".unity3d"; } if (obj != null) { ResDataManager.instance.AddEditorRes(node.resPath.path, obj); if (node.loaderFileComplete != null) { node.loaderFileComplete(node.resPath.path, node.param); } } else { Log.info("[ResLoadTool LoadFromLocalRes]加载失败!" + node.resPath.path); if (node.loaderError != null) { node.loaderError(node.resPath.path, "[ResLoadTool LoadFromLocalRes]加载失败!" + node.resPath.path); yield return(2); } } bool b = UpdateProgress(node.id); if (b) { if (node.loaderListProgress != null) { node.loaderListProgress(node.id, _listProgressDict[node.id], _listStateDict[node.id]); } if (CheckLoaded(node.id)) {//队列完成 if (node.loaderListComplete != null) { node.loaderListComplete(node.id, node.param); } RemoveList(node.id); } } yield return(2); } CoroutineDelegate.StopCoroutines(OnLocalLoadThread(node)); }