From c8d3f6efed25118373db76aacb93a987d3441259 Mon Sep 17 00:00:00 2001 From: hevinci Date: Wed, 28 Sep 2022 11:46:23 +0800 Subject: [PATCH] Update editor logic --- .../AssetBundleBuilder/AssetBundleBuilder.cs | 2 - .../AssetBundleBuilderSetting.cs | 5 -- .../AssetBundleBuilderWindow.cs | 13 ---- .../AssetBundleBuilderWindow.uxml | 1 - .../AssetBundleBuilder/BuildParameters.cs | 21 ------ .../BuildReport/ReportSummary.cs | 12 ---- .../BuildTasks/TaskCopyBuildinFiles.cs | 67 ------------------- .../BuildTasks/TaskCopyBuildinFiles.cs.meta | 11 --- .../BuildTasks/TaskCreatePatchManifest.cs | 20 +----- .../BuildTasks/TaskCreateReport.cs | 24 ------- .../VisualViewers/ReporterSummaryViewer.cs | 4 -- 11 files changed, 1 insertion(+), 179 deletions(-) delete mode 100644 Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyBuildinFiles.cs delete mode 100644 Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyBuildinFiles.cs.meta diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs index 2079263..838a942 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs @@ -59,7 +59,6 @@ namespace YooAsset.Editor new TaskCreatePatchManifest(), //创建清单文件 new TaskCreateReport(), //创建报告文件 new TaskCreatePatchPackage(), //制作补丁包 - new TaskCopyBuildinFiles(), //拷贝内置文件 }; } else if (buildParameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline) @@ -74,7 +73,6 @@ namespace YooAsset.Editor new TaskCreatePatchManifest(), //创建清单文件 new TaskCreateReport(), //创建报告文件 new TaskCreatePatchPackage(), //制作补丁包 - new TaskCopyBuildinFiles(), //拷贝内置文件 }; } else diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderSetting.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderSetting.cs index 28d0cf7..24d7661 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderSetting.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderSetting.cs @@ -20,11 +20,6 @@ namespace YooAsset.Editor /// public string BuildPackage = string.Empty; - /// - /// 内置资源标签(首包资源标签) - /// - public string BuildTags = string.Empty; - /// /// 压缩方式 /// diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs index a0c6c26..2f9934f 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs @@ -27,7 +27,6 @@ namespace YooAsset.Editor private TextField _buildOutputField; private EnumField _buildPipelineField; private EnumField _buildModeField; - private TextField _buildinTagsField; private PopupField _buildPackageField; private PopupField _encryptionField; private EnumField _compressionField; @@ -90,15 +89,6 @@ namespace YooAsset.Editor RefreshWindow(); }); - // 内置资源标签 - _buildinTagsField = root.Q("BuildinTags"); - _buildinTagsField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.BuildTags); - _buildinTagsField.RegisterValueChangedCallback(evt => - { - AssetBundleBuilderSettingData.IsDirty = true; - AssetBundleBuilderSettingData.Setting.BuildTags = _buildinTagsField.value; - }); - // 构建包裹 var buildPackageContainer = root.Q("BuildPackageContainer"); if (_buildPackageNames.Count > 0) @@ -204,7 +194,6 @@ namespace YooAsset.Editor { var buildMode = AssetBundleBuilderSettingData.Setting.BuildMode; bool enableElement = buildMode == EBuildMode.ForceRebuild; - _buildinTagsField.SetEnabled(enableElement); _encryptionField.SetEnabled(enableElement); _compressionField.SetEnabled(enableElement); _outputNameStyleField.SetEnabled(enableElement); @@ -239,10 +228,8 @@ namespace YooAsset.Editor buildParameters.BuildPipeline = AssetBundleBuilderSettingData.Setting.BuildPipeline; buildParameters.BuildMode = AssetBundleBuilderSettingData.Setting.BuildMode; buildParameters.BuildPackage = AssetBundleBuilderSettingData.Setting.BuildPackage; - buildParameters.BuildinTags = AssetBundleBuilderSettingData.Setting.BuildTags; buildParameters.VerifyBuildingResult = true; buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable; - buildParameters.CopyBuildinTagFiles = AssetBundleBuilderSettingData.Setting.BuildMode == EBuildMode.ForceRebuild; buildParameters.EncryptionServices = CreateEncryptionServicesInstance(); buildParameters.CompressOption = AssetBundleBuilderSettingData.Setting.CompressOption; buildParameters.OutputNameStyle = AssetBundleBuilderSettingData.Setting.OutputNameStyle; diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.uxml b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.uxml index 79f579f..a74ab9d 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.uxml +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.uxml @@ -10,7 +10,6 @@ - diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildParameters.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildParameters.cs index 741a835..60128a6 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildParameters.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildParameters.cs @@ -61,12 +61,6 @@ namespace YooAsset.Editor /// public string BuildPackage; - /// - /// 内置资源标签集合(首包资源标签) - /// 注意:分号为分隔符 - /// - public string BuildinTags; - /// /// 验证构建结果 @@ -77,12 +71,6 @@ namespace YooAsset.Editor /// 启用可寻址资源定位 /// public bool EnableAddressable = false; - - /// - /// 拷贝内置资源文件到StreamingAssets目录(首包资源文件) - /// - public bool CopyBuildinTagFiles = false; - /// /// 加密类 @@ -108,14 +96,5 @@ namespace YooAsset.Editor /// 忽略类型树变化 /// public bool IgnoreTypeTreeChanges = true; - - - /// - /// 获取内置资源标签列表(首包资源标签) - /// - public List GetBuildinTags() - { - return StringUtility.StringToStringList(BuildinTags, ';'); - } } } \ No newline at end of file diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportSummary.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportSummary.cs index 86d2345..65c4733 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportSummary.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportSummary.cs @@ -48,21 +48,11 @@ namespace YooAsset.Editor /// public string BuildPackage; - /// - /// 内置资源标签 - /// - public string BuildinTags; - /// /// 启用可寻址资源定位 /// public bool EnableAddressable; - /// - /// 拷贝内置资源文件 - /// - public bool CopyBuildinTagFiles; - /// /// 加密服务类名称 /// @@ -79,8 +69,6 @@ namespace YooAsset.Editor public int MainAssetTotalCount; public int AllBundleTotalCount; public long AllBundleTotalSize; - public int BuildinBundleTotalCount; - public long BuildinBundleTotalSize; public int EncryptedBundleTotalCount; public long EncryptedBundleTotalSize; public int RawBundleTotalCount; diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyBuildinFiles.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyBuildinFiles.cs deleted file mode 100644 index 2d766f9..0000000 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyBuildinFiles.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using UnityEditor; -using UnityEngine; - -namespace YooAsset.Editor -{ - [TaskAttribute("拷贝内置文件到流目录")] - public class TaskCopyBuildinFiles : IBuildTask - { - void IBuildTask.Run(BuildContext context) - { - var buildParametersContext = context.GetContextObject(); - if (buildParametersContext.Parameters.CopyBuildinTagFiles) - { - // 清空流目录 - AssetBundleBuilderHelper.ClearStreamingAssetsFolder(); - - // 拷贝内置文件 - CopyBuildinFilesToStreaming(buildParametersContext); - } - } - - private void CopyBuildinFilesToStreaming(BuildParametersContext buildParametersContext) - { - string streamingAssetsOutputDirectory = AssetBundleBuilderHelper.GetStreamingAssetsFolderPath(); - string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory(); - string packageName = buildParametersContext.Parameters.BuildPackage; - string packageCRC = buildParametersContext.OutputPackageCRC; - - // 加载补丁清单 - PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(pipelineOutputDirectory, packageName, packageCRC); - - // 拷贝文件列表 - foreach (var patchBundle in patchManifest.BundleList) - { - if (patchBundle.IsBuildin == false) - continue; - - string sourcePath = $"{pipelineOutputDirectory}/{patchBundle.BundleName}"; - string destPath = $"{streamingAssetsOutputDirectory}/{patchBundle.FileName}"; - EditorTools.CopyFile(sourcePath, destPath, true); - } - - // 拷贝清单文件 - { - string manifestFileName = YooAssetSettingsData.GetPatchManifestFileName(packageName, packageCRC); - string sourcePath = $"{pipelineOutputDirectory}/{manifestFileName}"; - string destPath = $"{streamingAssetsOutputDirectory}/{manifestFileName}"; - EditorTools.CopyFile(sourcePath, destPath, true); - } - - // 拷贝静态版本文件 - { - string versionFileName = YooAssetSettingsData.GetStaticVersionFileName(packageName); - string sourcePath = $"{pipelineOutputDirectory}/{versionFileName}"; - string destPath = $"{streamingAssetsOutputDirectory}/{versionFileName}"; - EditorTools.CopyFile(sourcePath, destPath, true); - } - - // 刷新目录 - AssetDatabase.Refresh(); - BuildRunner.Log($"内置文件拷贝完成:{streamingAssetsOutputDirectory}"); - } - } -} \ No newline at end of file diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyBuildinFiles.cs.meta b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyBuildinFiles.cs.meta deleted file mode 100644 index 6ac8176..0000000 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyBuildinFiles.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5c77e17c3a3a57548a218f1cd26f5a55 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs index 8f17399..7350977 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs @@ -31,7 +31,6 @@ namespace YooAsset.Editor patchManifest.EnableAddressable = buildParameters.EnableAddressable; patchManifest.OutputNameStyle = (int)buildParameters.OutputNameStyle; patchManifest.PackageName = buildParameters.BuildPackage; - patchManifest.BuildinTags = buildParameters.BuildinTags; patchManifest.BundleList = GetAllPatchBundle(context); patchManifest.AssetList = GetAllPatchAsset(context, patchManifest); @@ -76,8 +75,6 @@ namespace YooAsset.Editor var encryptionContext = context.GetContextObject(); List result = new List(1000); - - List buildinTags = buildParameters.Parameters.GetBuildinTags(); foreach (var bundleInfo in buildMapContext.BundleInfos) { var bundleName = bundleInfo.BundleName; @@ -86,29 +83,14 @@ namespace YooAsset.Editor long fileSize = GetBundleFileSize(bundleInfo, buildParameters); string[] tags = buildMapContext.GetBundleTags(bundleName); bool isEncrypted = encryptionContext.IsEncryptFile(bundleName); - bool isBuildin = IsBuildinBundle(tags, buildinTags); bool isRawFile = bundleInfo.IsRawFile; PatchBundle patchBundle = new PatchBundle(bundleName, fileHash, fileCRC, fileSize, tags); - patchBundle.SetFlagsValue(isEncrypted, isBuildin, isRawFile); + patchBundle.SetFlagsValue(isRawFile, isEncrypted); result.Add(patchBundle); } - return result; } - private bool IsBuildinBundle(string[] bundleTags, List buildinTags) - { - // 注意:没有任何分类标签的Bundle文件默认为内置文件 - if (bundleTags.Length == 0) - return true; - - foreach (var tag in bundleTags) - { - if (buildinTags.Contains(tag)) - return true; - } - return false; - } private string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext) { var buildMode = buildParametersContext.Parameters.BuildMode; diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs index 9904974..2ab0cc0 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs @@ -46,9 +46,7 @@ namespace YooAsset.Editor buildReport.Summary.BuildPipeline = buildParameters.BuildPipeline; buildReport.Summary.BuildMode = buildParameters.BuildMode; buildReport.Summary.BuildPackage = buildParameters.BuildPackage; - buildReport.Summary.BuildinTags = buildParameters.BuildinTags; buildReport.Summary.EnableAddressable = buildParameters.EnableAddressable; - buildReport.Summary.CopyBuildinTagFiles = buildParameters.CopyBuildinTagFiles; buildReport.Summary.EncryptionServicesClassName = buildParameters.EncryptionServices == null ? "null" : buildParameters.EncryptionServices.GetType().FullName; @@ -63,8 +61,6 @@ namespace YooAsset.Editor buildReport.Summary.MainAssetTotalCount = GetMainAssetCount(patchManifest); buildReport.Summary.AllBundleTotalCount = GetAllBundleCount(patchManifest); buildReport.Summary.AllBundleTotalSize = GetAllBundleSize(patchManifest); - buildReport.Summary.BuildinBundleTotalCount = GetBuildinBundleCount(patchManifest); - buildReport.Summary.BuildinBundleTotalSize = GetBuildinBundleSize(patchManifest); buildReport.Summary.EncryptedBundleTotalCount = GetEncryptedBundleCount(patchManifest); buildReport.Summary.EncryptedBundleTotalSize = GetEncryptedBundleSize(patchManifest); buildReport.Summary.RawBundleTotalCount = GetRawBundleCount(patchManifest); @@ -178,26 +174,6 @@ namespace YooAsset.Editor } return fileBytes; } - private int GetBuildinBundleCount(PatchManifest patchManifest) - { - int fileCount = 0; - foreach (var patchBundle in patchManifest.BundleList) - { - if (patchBundle.IsBuildin) - fileCount++; - } - return fileCount; - } - private long GetBuildinBundleSize(PatchManifest patchManifest) - { - long fileBytes = 0; - foreach (var patchBundle in patchManifest.BundleList) - { - if (patchBundle.IsBuildin) - fileBytes += patchBundle.FileSize; - } - return fileBytes; - } private int GetEncryptedBundleCount(PatchManifest patchManifest) { int fileCount = 0; diff --git a/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterSummaryViewer.cs b/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterSummaryViewer.cs index 1bb244f..ff2227d 100644 --- a/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterSummaryViewer.cs +++ b/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterSummaryViewer.cs @@ -67,10 +67,8 @@ namespace YooAsset.Editor _items.Add(new ItemWrapper("构建管线", $"{buildReport.Summary.BuildPipeline}")); _items.Add(new ItemWrapper("构建模式", $"{buildReport.Summary.BuildMode}")); _items.Add(new ItemWrapper("构建包裹", $"{buildReport.Summary.BuildPackage}")); - _items.Add(new ItemWrapper("内置资源标签", $"{buildReport.Summary.BuildinTags}")); _items.Add(new ItemWrapper("启用可寻址资源定位", $"{buildReport.Summary.EnableAddressable}")); - _items.Add(new ItemWrapper("拷贝内置资源文件", $"{buildReport.Summary.CopyBuildinTagFiles}")); _items.Add(new ItemWrapper("加密服务类名称", $"{buildReport.Summary.EncryptionServicesClassName}")); _items.Add(new ItemWrapper(string.Empty, string.Empty)); @@ -86,8 +84,6 @@ namespace YooAsset.Editor _items.Add(new ItemWrapper("主资源总数", $"{buildReport.Summary.MainAssetTotalCount}")); _items.Add(new ItemWrapper("资源包总数", $"{buildReport.Summary.AllBundleTotalCount}")); _items.Add(new ItemWrapper("资源包总大小", ConvertSize(buildReport.Summary.AllBundleTotalSize))); - _items.Add(new ItemWrapper("内置资源包总数", $"{buildReport.Summary.BuildinBundleTotalCount}")); - _items.Add(new ItemWrapper("内置资源包总大小", ConvertSize(buildReport.Summary.BuildinBundleTotalSize))); _items.Add(new ItemWrapper("加密资源包总数", $"{buildReport.Summary.EncryptedBundleTotalCount}")); _items.Add(new ItemWrapper("加密资源包总大小", ConvertSize(buildReport.Summary.EncryptedBundleTotalSize))); _items.Add(new ItemWrapper("原生资源包总数", $"{buildReport.Summary.RawBundleTotalCount}"));