Update AssetBundleBuilder

AssetBundleBuilder界面增加演练构建选项。
构建文件名增加版本信息。
pull/9/head
hevinci 2022-04-27 11:02:30 +08:00
parent 15dc047488
commit 775c724840
9 changed files with 44 additions and 7 deletions

View File

@ -26,7 +26,10 @@ namespace YooAsset.Editor
public BuildParametersContext(BuildParameters parameters) public BuildParametersContext(BuildParameters parameters)
{ {
Parameters = parameters; Parameters = parameters;
PipelineOutputDirectory = AssetBundleBuilderHelper.MakePipelineOutputDirectory(parameters.OutputRoot, parameters.BuildTarget); PipelineOutputDirectory = AssetBundleBuilderHelper.MakePipelineOutputDirectory(parameters.OutputRoot, parameters.BuildTarget);
if (parameters.DryRunBuild)
PipelineOutputDirectory += "_DryRunBuild";
} }
/// <summary> /// <summary>

View File

@ -30,6 +30,11 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public bool ForceRebuild = false; public bool ForceRebuild = false;
/// <summary>
/// 演练构建
/// </summary>
public bool DryRunBuild = false;
/// <summary> /// <summary>
/// 内置标签 /// 内置标签
/// </summary> /// </summary>

View File

@ -29,6 +29,7 @@ namespace YooAsset.Editor
private PopupField<string> _encryptionField; private PopupField<string> _encryptionField;
private Toggle _appendExtensionToggle; private Toggle _appendExtensionToggle;
private Toggle _forceRebuildToggle; private Toggle _forceRebuildToggle;
private Toggle _dryRunBuildToggle;
private TextField _buildTagsTxt; private TextField _buildTagsTxt;
@ -73,6 +74,7 @@ namespace YooAsset.Editor
_compressionField.Init(AssetBundleBuilderSettingData.Setting.CompressOption); _compressionField.Init(AssetBundleBuilderSettingData.Setting.CompressOption);
_compressionField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.CompressOption); _compressionField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.CompressOption);
_compressionField.style.width = 300; _compressionField.style.width = 300;
_compressionField.SetEnabled(AssetBundleBuilderSettingData.Setting.DryRunBuild == false);
_compressionField.RegisterValueChangedCallback(evt => _compressionField.RegisterValueChangedCallback(evt =>
{ {
AssetBundleBuilderSettingData.Setting.CompressOption = (ECompressOption)_compressionField.value; AssetBundleBuilderSettingData.Setting.CompressOption = (ECompressOption)_compressionField.value;
@ -94,6 +96,7 @@ namespace YooAsset.Editor
_encryptionField = new PopupField<string>(_encryptionServicesClassNames, defaultIndex); _encryptionField = new PopupField<string>(_encryptionServicesClassNames, defaultIndex);
_encryptionField.label = "Encryption"; _encryptionField.label = "Encryption";
_encryptionField.style.width = 300; _encryptionField.style.width = 300;
_encryptionField.SetEnabled(AssetBundleBuilderSettingData.Setting.DryRunBuild == false);
_encryptionField.RegisterValueChangedCallback(evt => _encryptionField.RegisterValueChangedCallback(evt =>
{ {
AssetBundleBuilderSettingData.Setting.EncyptionClassName = _encryptionField.value; AssetBundleBuilderSettingData.Setting.EncyptionClassName = _encryptionField.value;
@ -105,12 +108,14 @@ namespace YooAsset.Editor
_encryptionField = new PopupField<string>(); _encryptionField = new PopupField<string>();
_encryptionField.label = "Encryption"; _encryptionField.label = "Encryption";
_encryptionField.style.width = 300; _encryptionField.style.width = 300;
_encryptionField.SetEnabled(AssetBundleBuilderSettingData.Setting.DryRunBuild == false);
encryptionContainer.Add(_encryptionField); encryptionContainer.Add(_encryptionField);
} }
// 附加后缀格式 // 附加后缀格式
_appendExtensionToggle = root.Q<Toggle>("AppendExtension"); _appendExtensionToggle = root.Q<Toggle>("AppendExtension");
_appendExtensionToggle.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.AppendExtension); _appendExtensionToggle.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.AppendExtension);
_appendExtensionToggle.SetEnabled(AssetBundleBuilderSettingData.Setting.DryRunBuild == false);
_appendExtensionToggle.RegisterValueChangedCallback(evt => _appendExtensionToggle.RegisterValueChangedCallback(evt =>
{ {
AssetBundleBuilderSettingData.Setting.AppendExtension = _appendExtensionToggle.value; AssetBundleBuilderSettingData.Setting.AppendExtension = _appendExtensionToggle.value;
@ -119,12 +124,25 @@ namespace YooAsset.Editor
// 强制构建 // 强制构建
_forceRebuildToggle = root.Q<Toggle>("ForceRebuild"); _forceRebuildToggle = root.Q<Toggle>("ForceRebuild");
_forceRebuildToggle.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.ForceRebuild); _forceRebuildToggle.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.ForceRebuild);
_forceRebuildToggle.SetEnabled(AssetBundleBuilderSettingData.Setting.DryRunBuild == false);
_forceRebuildToggle.RegisterValueChangedCallback(evt => _forceRebuildToggle.RegisterValueChangedCallback(evt =>
{ {
AssetBundleBuilderSettingData.Setting.ForceRebuild = _forceRebuildToggle.value; AssetBundleBuilderSettingData.Setting.ForceRebuild = _forceRebuildToggle.value;
_buildTagsTxt.SetEnabled(_forceRebuildToggle.value); _buildTagsTxt.SetEnabled(_forceRebuildToggle.value);
}); });
// 演练构建
_dryRunBuildToggle = root.Q<Toggle>("DryRunBuild");
_dryRunBuildToggle.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.DryRunBuild);
_dryRunBuildToggle.RegisterValueChangedCallback(evt =>
{
AssetBundleBuilderSettingData.Setting.DryRunBuild = _dryRunBuildToggle.value;
_compressionField.SetEnabled(_dryRunBuildToggle.value == false);
_encryptionField.SetEnabled(_dryRunBuildToggle.value == false);
_appendExtensionToggle.SetEnabled(_dryRunBuildToggle.value == false);
_forceRebuildToggle.SetEnabled(_dryRunBuildToggle.value == false);
});
// 内置标签 // 内置标签
_buildTagsTxt = root.Q<TextField>("BuildinTags"); _buildTagsTxt = root.Q<TextField>("BuildinTags");
_buildTagsTxt.SetEnabled(_forceRebuildToggle.value); _buildTagsTxt.SetEnabled(_forceRebuildToggle.value);
@ -188,6 +206,7 @@ namespace YooAsset.Editor
buildParameters.AppendFileExtension = _appendExtensionToggle.value; buildParameters.AppendFileExtension = _appendExtensionToggle.value;
buildParameters.EncryptionServices = CreateEncryptionServicesInstance(); buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
buildParameters.ForceRebuild = _forceRebuildToggle.value; buildParameters.ForceRebuild = _forceRebuildToggle.value;
buildParameters.DryRunBuild = _dryRunBuildToggle.value;
buildParameters.BuildinTags = _buildTagsTxt.value; buildParameters.BuildinTags = _buildTagsTxt.value;
AssetBundleBuilder builder = new AssetBundleBuilder(); AssetBundleBuilder builder = new AssetBundleBuilder();

View File

@ -7,6 +7,7 @@
<ui:VisualElement name="EncryptionContainer" style="height: 24px;" /> <ui:VisualElement name="EncryptionContainer" style="height: 24px;" />
<ui:Toggle label="Append Extension" name="AppendExtension" style="height: 15px;" /> <ui:Toggle label="Append Extension" name="AppendExtension" style="height: 15px;" />
<ui:Toggle label="Force Rebuild" name="ForceRebuild" /> <ui:Toggle label="Force Rebuild" name="ForceRebuild" />
<ui:Toggle label="Dry Run Build" name="DryRunBuild" />
<ui:TextField picking-mode="Ignore" label="Buildin Tags" name="BuildinTags" /> <ui:TextField picking-mode="Ignore" label="Buildin Tags" name="BuildinTags" />
<ui:Button text="构建" display-tooltip-when-elided="true" name="Build" style="height: 50px; background-color: rgb(40, 106, 42); margin-top: 10px;" /> <ui:Button text="构建" display-tooltip-when-elided="true" name="Build" style="height: 50px; background-color: rgb(40, 106, 42); margin-top: 10px;" />
</ui:VisualElement> </ui:VisualElement>

View File

@ -28,8 +28,9 @@ namespace YooAsset.Editor
// 拷贝Report文件 // 拷贝Report文件
{ {
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettings.ReportFileName}"; string reportFileName = YooAssetSettingsData.GetReportFileName(buildParameters.Parameters.BuildVersion);
string destPath = $"{packageDirectory}/{YooAssetSettings.ReportFileName}"; string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{reportFileName}";
string destPath = $"{packageDirectory}/{reportFileName}";
EditorTools.CopyFile(sourcePath, destPath, true); EditorTools.CopyFile(sourcePath, destPath, true);
UnityEngine.Debug.Log($"拷贝构建报告文件到:{destPath}"); UnityEngine.Debug.Log($"拷贝构建报告文件到:{destPath}");
} }

View File

@ -86,7 +86,7 @@ namespace YooAsset.Editor
} }
// 删除旧文件 // 删除旧文件
string filePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettings.ReportFileName}"; string filePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.GetReportFileName(buildParameters.Parameters.BuildVersion)}";
if (File.Exists(filePath)) if (File.Exists(filePath))
File.Delete(filePath); File.Delete(filePath);

View File

@ -26,7 +26,7 @@ namespace YooAsset.Editor
throw new Exception("输出目录不能为空"); throw new Exception("输出目录不能为空");
// 增量更新时候的必要检测 // 增量更新时候的必要检测
if (buildParameters.Parameters.ForceRebuild == false) if (buildParameters.Parameters.DryRunBuild == false && buildParameters.Parameters.ForceRebuild == false)
{ {
// 检测历史版本是否存在 // 检测历史版本是否存在
if (AssetBundleBuilderHelper.HasAnyPackageVersion(buildParameters.Parameters.BuildTarget, buildParameters.Parameters.OutputRoot) == false) if (AssetBundleBuilderHelper.HasAnyPackageVersion(buildParameters.Parameters.BuildTarget, buildParameters.Parameters.OutputRoot) == false)
@ -49,7 +49,7 @@ namespace YooAsset.Editor
} }
// 如果是强制重建 // 如果是强制重建
if (buildParameters.Parameters.ForceRebuild) if (buildParameters.Parameters.DryRunBuild == false && buildParameters.Parameters.ForceRebuild)
{ {
// 删除平台总目录 // 删除平台总目录
string platformDirectory = $"{buildParameters.Parameters.OutputRoot}/{buildParameters.Parameters.BuildTarget}"; string platformDirectory = $"{buildParameters.Parameters.OutputRoot}/{buildParameters.Parameters.BuildTarget}";

View File

@ -28,7 +28,7 @@ namespace YooAsset
/// <summary> /// <summary>
/// 构建输出的报告文件 /// 构建输出的报告文件
/// </summary> /// </summary>
public const string ReportFileName = "BuildReport.json"; public const string ReportFileName = "BuildReport";
/// <summary> /// <summary>
/// 静态版本文件 /// 静态版本文件

View File

@ -32,6 +32,14 @@ namespace YooAsset
} }
} }
/// <summary>
/// 获取构建报告文件名
/// </summary>
public static string GetReportFileName(int resourceVersion)
{
return $"{YooAssetSettings.ReportFileName}_{resourceVersion}.json";
}
/// <summary> /// <summary>
/// 获取补丁清单文件完整名称 /// 获取补丁清单文件完整名称
/// </summary> /// </summary>