static List <UabInfoItem> createUabInfo(AssetBundleManifest abm) { List <UabInfoItem> items = new List <UabInfoItem>(); string[] allbundles = abm.GetAllAssetBundles(); foreach (string bundle in allbundles) { string bundlename = Path.GetFileName(bundle); string bundlepath = UabFileUtil.PathCombine(UabEditorDef.UabRoot, UabDef.UAB_BUNDLE_ROOT, bundle); UabInfoItem item = new UabInfoItem(); item.N = bundlename; item.S = UabFileUtil.GetFileSize(bundlepath); item.H = UabFileUtil.CalcFileMD5(bundlepath); item.R = false; string[] d = abm.GetDirectDependencies(bundle); item.D = new string[d.Length]; for (int i = 0; i < d.Length; i++) { item.D[i] = Path.GetFileNameWithoutExtension(d[i]); } items.Add(item); } checkLoopDepend(items); return(items); }
static void _checkLoopDepend(UabInfoItem item, Dictionary <string, UabInfoItem> dict, HashSet <string> checkedItem, List <string> hspath = null) { string n = Path.GetFileNameWithoutExtension(item.N); if (checkedItem.Contains(n) || item.D.Length == 0) { if (!checkedItem.Contains(n)) { checkedItem.Add(n); } return; } if (hspath == null) { hspath = new List <string>(); } hspath.Add(n); bool loopdepend = false; foreach (string d in item.D) { if (hspath.Contains(d)) { string str = ""; for (int i = 0; i < hspath.Count; i++) { str += $"{hspath[i]} -> "; } str = str.Substring(0, str.Length - 4); str = str + " contain: " + d; //throw new Exception($"发现循环依赖 [ {str} ]"); Debug.LogError($"发现循环依赖 [ {str} ]"); loopdepend = true; break; } if (loopdepend) { return; } _checkLoopDepend(dict[d], dict, checkedItem, hspath); } hspath.Remove(n); if (!checkedItem.Contains(n)) { checkedItem.Add(n); } }