// 搜索 static void SearchDependencies(ResNode root) { if (root == null) { return; } //Debug.Log("输入依赖目录 = "+root.assetsPath); var list = GetDependencies(root.assetsPath); if (list == null || list.Length <= 0) { return; } List <ResNode> newNode = new List <ResNode>(); foreach (var assetsPath in list) { if (ignoreConfig.IsMatch(assetsPath)) { continue; } if (root.assetsPath.Contains("Art/Prefab/UI") && assetsPath.Contains("Art/Prefab/UI")) { continue; } bool isNew = false; ResNode node = null; if (!resNodeDic.TryGetValue(assetsPath, out node)) { isNew = true; node = new ResNode(); node.assetsPath = assetsPath; node.ResetAssetsBundleName(); resNodeDic[assetsPath] = node; newNode.Add(node); } if (!isNew) { // 已有节点需要考虑环形依赖 node.AddPreviousNode(root); root.AddNextNode(node); } else { // 新发现的节点 node.AddPreviousNode(root); root.AddNextNode(node); } } // 递归搜索新节点 foreach (var node in newNode) { SearchDependencies(node); } }
// 生成依赖树 static ResNode GenTree(string assetsPath) { ResNode node = null; if (!resNodeDic.TryGetValue(assetsPath, out node)) { node = new ResNode(); node.assetsPath = assetsPath; node.ResetAssetsBundleName(); resNodeDic[assetsPath] = node; node.IsRes = true; SearchDependencies(node); } node.IsRes = true; node.ResetAssetsBundleName(); return(node); }