/// <summary> /// 异步加载一个依赖包 /// </summary> /// <param name="relyBundleName"></param> /// <param name="callBack"></param> public static void LoadRelyBundleAsync(string relyBundleName, RelyBundleLoadCallBack callBack) { if (s_relyBundle.ContainsKey(relyBundleName)) { RelyBundle tmp = s_relyBundle[relyBundleName]; tmp.relyCount++; callBack(LoadState.CompleteState, tmp); } else { //先占位,避免重复加载 s_relyBundle.Add(relyBundleName, null); ResourcesConfig configTmp = ResourcesConfigManager.GetRelyBundleConfig(relyBundleName); string path = GetBundlePath(configTmp); ResourceIOTool.AssetsBundleLoadAsync(path, (LoadState state, AssetBundle bundle) => { if (!state.isDone) { callBack(state, null); } else { callBack(state, AddRelyBundle(relyBundleName, bundle)); } }); } }
//加载一个依赖包 public static RelyBundle LoadRelyBundle(string relyBundleName) { RelyBundle tmp = null; if (s_relyBundle.ContainsKey(relyBundleName)) { tmp = s_relyBundle[relyBundleName]; tmp.relyCount++; } else { ResourcesConfig configTmp = ResourcesConfigManager.GetRelyBundleConfig(relyBundleName); string path = GetBundlePath(configTmp); tmp = AddRelyBundle(relyBundleName, AssetBundle.LoadFromFile(path)); } return(tmp); }