public static void FilterDotNeedNode(Dictionary <string, AssetNode> needDict, List <AssetNode> needRoots) { int count = needRoots.Count; for (int i = 0; i < needRoots.Count; i++) { EditorUtility.DisplayProgressBar("过滤不需要打包的节点", i + "/" + count, 1f * i / count); needRoots[i].FilterDotNeedNode(needDict); } if (isLog) { AssetNode.PrintNodeTree(needRoots, "过滤不需要打包的节点"); } EditorUtility.ClearProgressBar(); }
public static void MergeParentCountOnce(List <AssetNode> roots) { int count = roots.Count; int index = 0; foreach (AssetNode node in roots) { EditorUtility.DisplayProgressBar("入度为1的节点自动打包到上一级节点", index + "/" + count, 1f * (index++) / count); node.MergeParentCountOnce(); } if (isLog) { AssetNode.PrintNodeTree(roots, "入度为1的节点自动打包到上一级节点"); } EditorUtility.ClearProgressBar(); }
public static void RemoveParentShare(List <AssetNode> roots) { int count = roots.Count; int index = 0; foreach (AssetNode node in roots) { EditorUtility.DisplayProgressBar("移除父节点的依赖和自己依赖相同的节点", index + "/" + count, 1f * (index++) / count); node.RemoveParentShare(); } if (isLog) { AssetNode.PrintNodeTree(roots, "移除父节点的依赖和自己依赖相同的节点"); } EditorUtility.ClearProgressBar(); }
public static List <AssetNode> FindRoots(Dictionary <string, AssetNode> nodeDict) { int count = nodeDict.Count; int index = 0; List <AssetNode> roots = new List <AssetNode>(); foreach (KeyValuePair <string, AssetNode> kvp in nodeDict) { EditorUtility.DisplayProgressBar("寻找入度为0的节点", index + "/" + count, 1f * (index++) / count); AssetNode node = kvp.Value; if (node.IsRoot) { roots.Add(node); } } if (isLog) { AssetNode.PrintNodeTree(roots, "寻找入度为0的节点"); } EditorUtility.ClearProgressBar(); return(roots); }
/// <summary> /// /// </summary> /// <param name="resList">需要打包的列表</param> /// <param name="filterDirList">过滤的目录</param> /// <param name="filterExts">过滤的扩展名</param> /// <param name="imageExts"></param> /// <param name="isSpriteTag"></param> /// <param name="assetbundleExt"></param> /// <returns></returns> public static Dictionary <string, AssetNode> GenerateAllNode(List <string> resList, List <string> filterDirList, List <string> filterExts, List <string> imageExts, bool isSpriteTag = false, string assetbundleExt = ".assetbundle") { Dictionary <string, AssetNode> nodeDict = new Dictionary <string, AssetNode>(); Dictionary <string, AssetNode> spriteTagPackageDict = new Dictionary <string, AssetNode>(); List <AssetNode> spriteTagPackageList = new List <AssetNode>(); string[] dependencies = AssetDatabase.GetDependencies(resList.ToArray()); int count = dependencies.Length; for (int i = 0; i < count; i++) { EditorUtility.DisplayProgressBar("生成所有节点", i + "/" + count, 1f * i / count); string path = dependencies[i]; bool isFilterDir = false; if (filterDirList.Count > 0) { foreach (string filterDir in filterDirList) { if (path.IndexOf(filterDir, StringComparison.Ordinal) != -1) { isFilterDir = true; break; } } } if (isFilterDir) { continue; } string ext = Path.GetExtension(path).ToLower(); if (filterExts.IndexOf(ext) != -1) { continue; } AssetImporter assetImporter = AssetImporter.GetAtPath(path); if (!string.IsNullOrEmpty(assetImporter.assetBundleName)) { assetImporter.assetBundleName = string.Empty; } if (isSpriteTag && imageExts.IndexOf(ext) != -1) { TextureImporter importer = AssetImporter.GetAtPath(path) as TextureImporter; if (importer.textureType == TextureImporterType.Sprite && !string.IsNullOrEmpty(importer.spritePackingTag)) { importer.assetBundleName = importer.spritePackingTag + assetbundleExt; AssetNode spriteTagPackageNode; if (!spriteTagPackageDict.TryGetValue(importer.spritePackingTag, out spriteTagPackageNode)) { spriteTagPackageNode = new AssetNode(); spriteTagPackageNode.path = importer.spritePackingTag; spriteTagPackageDict.Add(spriteTagPackageNode.path, spriteTagPackageNode); spriteTagPackageList.Add(spriteTagPackageNode); } AssetNode spriteTagNode = new AssetNode(); spriteTagNode.path = path; spriteTagPackageNode.AddAsset(spriteTagNode); continue; } } AssetNode node = new AssetNode(); node.path = path; nodeDict.Add(node.path, node); } if (isLog) { AssetNode.PrintNodeDict(nodeDict, "nodeDict"); } if (isLog) { AssetNode.PrintNodeTree(spriteTagPackageList, "图集"); } EditorUtility.ClearProgressBar(); return(nodeDict); }