/// <summary> /// /// </summary> public Dictionary <string, FileHashData> Build() { if (!Directory.Exists(m_rootFolder)) { return(new Dictionary <string, FileHashData>()); } // 対象ファイルのフィルタリング var allFiles = Directory.GetFiles(m_rootFolder, "*", SearchOption.AllDirectories); var filterdList = allFiles .Where(path => m_regexes.Any(r => r.IsMatch(path))) .Select(p => p.ToConvertDelimiter()) .ToArray(); // テーブル var list = new Dictionary <string, FileHashData>(); using (var dialog = new ProgressDialogScope("Calc FileHash", filterdList.Length)) { for (int i = 0; i < filterdList.Length; i++) { var file = filterdList[i]; var path = file.Replace("\\", "/"); var key = path.Replace(m_rootFolder, string.Empty); var info = new FileInfo(path); var hash = m_hashCalclater.Calclate(info); list.Add(key, new FileHashData { Key = key, Hash = hash, FileInfo = info }); dialog.Show(key + " == " + hash, i); } } return(list); }
/// <summary> /// アセットバンドル生成結果配列の作成 /// </summary> public IList <IBundleFileManifest> CreatePackageList( IBundleBuildConfig config, IReadOnlyList <string> buildAssets, IList <IBundlePackRule> packageConfigList ) { var packageTable = new Dictionary <string, IBundleFileManifest>(); var buildAssetTmp = new List <string>(buildAssets); var packList = packageConfigList.OrderBy(p => - p.Priority).ToArray(); using (var scope = new ProgressDialogScope("Calclate Package", packList.Length)) { for (var i = 0; i < packList.Length; i++) { var pack = packList[i]; scope.Show(pack.Identifier, i); var bundles = Package(config, pack, ref buildAssetTmp); foreach (var b in bundles) { if (packageTable.ContainsKey(b.ABName)) { packageTable[b.ABName].Merge(b); } else { packageTable.Add(b.ABName, b); } } } } return(packageTable.Values.ToArray()); }
protected override void DoProcess(RuntimePlatform platform, UnityEditor.BuildTarget target, IBundleBuildConfig settings, ABBuildResult result, IList <IBundleFileManifest> bundleList) { var outputPath = OutputPath.Get(platform); var list = bundleList.OrderBy(c => c.ABName).ToArray(); var manifest = result.Manifest; var packResult = new StringBuilder(); packResult.AppendLine("[Bundle List]"); using (var scope = new ProgressDialogScope("Bundle List", list.Length * 2)) { for (int i = 0; i < list.Length; i++) { packResult.AppendLine(list[i].ABName); } packResult.AppendLine("============================="); for (int i = 0; i < list.Length; i++) { var bundle = list[i]; scope.Show(bundle.ABName, i); AppendDependencies(packResult, bundle, manifest); } } var assetsList = new StringBuilder(); // Bundle List assetsList.AppendLine("[Bundle Assets dependencies]"); using (var scope = new ProgressDialogScope("Bundle Assets List", list.Length)) { for (int i = 0; i < list.Length; i++) { var d = bundleList[i]; assetsList.AppendFormat("{0} : {1}", i + 1, d.ABName) .AppendLine(); scope.Show(d.ABName, i); foreach (var path in d.Assets) { assetsList .Append(" ") .AppendFormat("{0}", path) .AppendLine(); } } } if (Directory.Exists(outputPath.BasePath)) { Directory.CreateDirectory(outputPath.BasePath); } var resultContents = new[] { new { name = nameof(packResult), content = packResult }, new { name = nameof(assetsList), content = assetsList }, }; foreach (var c in resultContents) { var filePath = outputPath.ToLocation(c.name + ".txt"); File.WriteAllText(filePath.FullPath, c.content.ToString()); } }
//========================================= // 関数 //========================================= /// <summary> /// ビルドマップを作成 /// </summary> protected override void DoProcess(RuntimePlatform platform, BuildTarget target, IBundleBuildConfig settings, ABBuildResult result, IList <IBundleFileManifest> bundleList) { var json = new BuildMapDataTable(); var buildMapFile = m_buildMapPath.Get(platform); var bundleDirectory = OutputPath.Get(platform); // 外部情報 var manifest = result.Manifest; var prefix = settings.TargetDirPath; json.Prefix = prefix; var table = bundleList.ToDictionary(c => c.ABName, c => c.Identifier); using (var scope = new ProgressDialogScope("Create Bundle Manifest : " + buildMapFile, bundleList.Count)) { // テーブル作成 for (int i = 0; i < bundleList.Count; i++) { // BuildFileData var fileData = bundleList[i]; // Path var file = bundleDirectory.ToLocation(fileData.ABName); // Create BuildMap Data var d = CreateBuildData(file, fileData, table, manifest); scope.Show(fileData.ABName, i); json.Add(d); } } var addresses = bundleList .SelectMany(c => c.Address) .Distinct() .ToArray(); using (var scope = new ProgressDialogScope("Create Asset Table : " + buildMapFile, addresses.Length)) { for (int i = 0; i < addresses.Length; i++) { var address = addresses[i]; var path = address.StartsWith(prefix) ? address : prefix + address; var d = new AssetBuildData { Path = address, Guid = AssetDatabase.AssetPathToGUID(path) }; scope.Show(address, i); json.Add(d); } } var builder = m_builder.Build(); builder.Write(buildMapFile.FullPath, json); }
public override IReadOnlyList <string> GetFiles() { var folderPath = AssetDatabase.GetAssetPath(m_rootFolder); var regexes = new List <Regex>(); foreach (var pattern in m_ignoreRegex) { regexes.Add(new Regex(pattern)); } var list = new List <string>(); var files = AssetDatabase .FindAssets($"t:{nameof(UnityEngine.Object)}", new[] { folderPath }) .Select(c => AssetDatabase.GUIDToAssetPath(c)) .Distinct() //サブアセットがダブるので .ToArray(); using (var scope = new ProgressDialogScope(folderPath, files.Length)) { for (var i = 0; i < files.Length; i++) { var filePath = files[i].ToConvertDelimiter(); scope.Show(filePath, i); if (AssetDatabase.IsValidFolder(filePath)) { continue; } var isIgnore = false; foreach (var regex in regexes) { if (regex.IsMatch(filePath)) { isIgnore = true; break; } } if (isIgnore) { continue; } list.Add(filePath); } return(list); } }
/// <summary> /// /// </summary> public virtual IReadOnlyList <string> Refine(string[] allAssetPaths) { var list = new List <string>(1000); using (var scope = new ProgressDialogScope("Target File Filtering...", allAssetPaths.Length)) { for (int i = 0; i < allAssetPaths.Length; i++) { var name = allAssetPaths[i]; scope.Show(name, i); if (Contains(name)) { list.Add(name); } } } return(list); }