public static void ExportABHashs(AssetBundleManifest mainfest, List <Frame.ABFile> abs = null) { bool save = abs == null; if (abs == null) { abs = abIndex.files; } abIndex.files.Clear(); AssetDatabase.RemoveUnusedAssetBundleNames(); var names = AssetDatabase.GetAllAssetBundleNames(); ABNameDefineSet defineSet = GetNameDefineSet(); List <string> garbages = new List <string>(); foreach (var abName in names) { FileInfo fileInfo = new FileInfo(Frame.Helper.CombineWithSlash(GetABFloder(), abName)); if (!fileInfo.Exists) { List <string> srcfiles = GetErrorABSource(abName); if (srcfiles.Count > 0) { StringBuilder sb = new StringBuilder(); foreach (var file in srcfiles) { sb.Append(string.Format("Error AB Define=>{0},", file)); } BuildLog.WriteLine(sb.ToString()); } garbages.Add(abName); } else { var info = new Frame.ABFile(); info.name = abName; info.children.AddRange(mainfest.GetAllDependencies(abName)); info.hash = mainfest.GetAssetBundleHash(abName).ToString(); info.size = (int)fileInfo.Length; try { info.persistent = defineSet.defineMap[abName].persistent; } catch (System.Exception ex) { Debug.LogError(string.Format("Path Error! AB name:" + abName)); } mABIndex.files.Add(info); } } if (save) { SaveABIndex(); } }
void MakeChildren(ABTaker taker) { Frame.ABFile info = VersionService2.Instance.GetAB(taker.name); for (int i = 0; i < info.children.Count; ++i) { var name = info.children[i]; ABTaker child = null; if (takerMap_.TryGetValue(name, out child)) { taker.AddChild(child); } else { Debug.Assert(child != null); } } }
public ABTaker LoadDependenceFromDisk(string abName) { if (string.IsNullOrEmpty(abName)) { Debug.LogError("Empty ab:"); return(null); } ABTaker abtaker; if (takerMap_.TryGetValue(abName, out abtaker)) { return(abtaker); } string fullPath = Frame.Helper.CombineWithSlash(Frame.FrameOption.Files.sdABFloder, abName); if (File.Exists(fullPath)) { try { Frame.Helper.BeginWatch(abName); var data = File.ReadAllBytes(fullPath); abtaker = new ABTaker(); //Debug.LogWarning("ABNAME:" + abName); abtaker.ab = AssetBundle.LoadFromMemory(data); } catch (Exception exc) { Debug.LogError(exc.Message); } Frame.ABFile info = VersionService2.Instance.GetAB(abName); abtaker.name = abName; abtaker.persistent = info.persistent; if (abtaker.persistent) { abtaker.ab.LoadAllAssets(); } MakeChildren(abtaker); Frame.Helper.EndWatch(); CacheAB(abName, abtaker); return(abtaker); } return(null); }
public void GetAllDependencies(ref List <string> names, string abName) { if (string.IsNullOrEmpty(abName)) { return; } if (names.Contains(abName) || takerMap_.ContainsKey(abName)) { return; } Frame.ABFile info = VersionService2.Instance.GetAB(abName); if (info != null) { for (int i = 0; i < info.children.Count; ++i) { GetAllDependencies(ref names, info.children[i]); } } names.Add(abName); }
public AssetBundleIndex GetIncrementResourceList(AssetBundleIndex list0, AssetBundleIndex list1) { if (list1 == null) { return(null); } Dictionary <string, ABFile> map0 = list0 == null ? null : list0.abMap; Dictionary <string, ABFile> map1 = list1.abMap; AssetBundleIndex incremetList = new AssetBundleIndex(); foreach (var data in map1) { ABFile info = null; if (map0 == null || !map0.TryGetValue(data.Key, out info) || info.hash != data.Value.hash) { incremetList.files.Add(data.Value); } } return(incremetList); }