/// <summary> /// 获取ab相关依赖。getAll 要不要排除大厅公用。yzs /// </summary> /// <param name="abname"></param> /// <param name="getAll">true 不要排除,false 要排除</param> /// <returns></returns> public string[] GetAllDependencies(string abname, bool getAll = true) { if (!manifestMap.ContainsKey(abname)) { if (!manifestMap.ContainsKey(AppConst.LoadAssetBundlePath)) { byte[] stream = null; if ("".Equals(AppConst.LoadAssetBundlePath)) { stream = File.ReadAllBytes(Util.DataPath + AppConst.AssetDir); } else if (AppConst.DebugMode) { stream = File.ReadAllBytes(Util.DataPath + AppConst.LoadAssetBundlePath + AppConst.dirSep + AppConst.LoadAssetBundlePath); } else { stream = File.ReadAllBytes(Util.DataPath + AppConst.LoadAssetBundlePath); } assetbundle = AssetBundle.LoadFromMemory(stream); manifestMap[AppConst.LoadAssetBundlePath] = assetbundle.LoadAsset <AssetBundleManifest>("AssetBundleManifest"); stream = null; } manifestMap[abname] = manifestMap[AppConst.LoadAssetBundlePath]; } AssetBundleManifest abm = manifestMap[abname]; if (abm == null) { Util.LogError("Cannot find abname= " + abname + " AssetBundleManifest= " + AppConst.LoadAssetBundlePath); return(new string[0]); } if (getAll || abm.Equals(manifest)) { return(abm.GetAllDependencies(abname)); } //排除大厅,,,想了想,,,其实没啥用。。大厅重新加载ab时候检查 关联文件那个方法我挪到 if外面。。每次都检查一下关联有没有掉了的。了事。。 string[] md = manifest.GetAllAssetBundles(); string[] td = abm.GetAllDependencies(abname); List <string> reList = new List <string>(); string s; for (int i = 0; i < td.Length; ++i) { s = td[i]; if (System.Array.IndexOf(md, s) == -1) { reList.Add(s); } } return(reList.ToArray()); }