Bundle build system adds builtin files copy options

资源构建增加内置文件拷贝的选项
pull/13/head
hevinci 2022-05-21 22:24:05 +08:00
parent 0dcbe0574c
commit 2dd3ba847e
9 changed files with 44 additions and 16 deletions

View File

@ -16,7 +16,7 @@ namespace YooAsset.Editor
public EBuildMode BuildMode = EBuildMode.ForceRebuild;
/// <summary>
/// 内置资源标签
/// 内置资源标签(首包资源标签)
/// </summary>
public string BuildTags = string.Empty;
@ -34,5 +34,10 @@ namespace YooAsset.Editor
/// 附加后缀格式
/// </summary>
public bool AppendExtension = false;
/// <summary>
/// 拷贝内置资源文件(首包资源文件)
/// </summary>
public bool CopyBuildinTagFiles = true;
}
}

View File

@ -25,11 +25,12 @@ namespace YooAsset.Editor
private TextField _buildOutputField;
private IntegerField _buildVersionField;
private EnumField _buildModeField;
private TextField _buildTagsField;
private TextField _buildinTagsField;
private PopupField<string> _encryptionField;
private EnumField _compressionField;
private Toggle _appendExtensionToggle;
private Toggle _copyBuildinTagFilesToggle;
public void CreateGUI()
{
try
@ -76,11 +77,11 @@ namespace YooAsset.Editor
});
// 内置资源标签
_buildTagsField = root.Q<TextField>("BuildinTags");
_buildTagsField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.BuildTags);
_buildTagsField.RegisterValueChangedCallback(evt =>
_buildinTagsField = root.Q<TextField>("BuildinTags");
_buildinTagsField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.BuildTags);
_buildinTagsField.RegisterValueChangedCallback(evt =>
{
AssetBundleBuilderSettingData.Setting.BuildTags = _buildTagsField.value;
AssetBundleBuilderSettingData.Setting.BuildTags = _buildinTagsField.value;
});
// 加密方法
@ -123,6 +124,14 @@ namespace YooAsset.Editor
AssetBundleBuilderSettingData.Setting.AppendExtension = _appendExtensionToggle.value;
});
// 拷贝首包文件
_copyBuildinTagFilesToggle = root.Q<Toggle>("CopyBuildinFiles");
_copyBuildinTagFilesToggle.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.CopyBuildinTagFiles);
_copyBuildinTagFilesToggle.RegisterValueChangedCallback(evt =>
{
AssetBundleBuilderSettingData.Setting.CopyBuildinTagFiles = _copyBuildinTagFilesToggle.value;
});
// 构建按钮
var buildButton = root.Q<Button>("Build");
buildButton.clicked += BuildButton_clicked; ;
@ -141,11 +150,13 @@ namespace YooAsset.Editor
private void RefreshWindow()
{
bool enableElement = AssetBundleBuilderSettingData.Setting.BuildMode == EBuildMode.ForceRebuild;
_buildTagsField.SetEnabled(enableElement);
var buildMode = AssetBundleBuilderSettingData.Setting.BuildMode;
bool enableElement = buildMode == EBuildMode.ForceRebuild;
_buildinTagsField.SetEnabled(enableElement);
_encryptionField.SetEnabled(enableElement);
_compressionField.SetEnabled(enableElement);
_appendExtensionToggle.SetEnabled(enableElement);
_copyBuildinTagFilesToggle.SetEnabled(buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild);
}
private void BuildButton_clicked()
{
@ -172,10 +183,11 @@ namespace YooAsset.Editor
buildParameters.BuildTarget = _buildTarget;
buildParameters.BuildMode = (EBuildMode)_buildModeField.value;
buildParameters.BuildVersion = _buildVersionField.value;
buildParameters.BuildinTags = _buildTagsField.value;
buildParameters.BuildinTags = _buildinTagsField.value;
buildParameters.VerifyBuildingResult = true;
buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
buildParameters.AppendFileExtension = _appendExtensionToggle.value;
buildParameters.CopyBuildinTagFiles = _copyBuildinTagFilesToggle.value;
buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
buildParameters.CompressOption = (ECompressOption)_compressionField.value;

View File

@ -7,6 +7,7 @@
<ui:VisualElement name="EncryptionContainer" style="height: 24px;" />
<uie:EnumField label="Compression" value="Center" name="Compression" />
<ui:Toggle label="Append Extension" name="AppendExtension" style="height: 15px;" />
<ui:Toggle label="Copy BuildinTag Files" name="CopyBuildinFiles" style="height: 15px;" />
<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:VisualElement>

View File

@ -30,7 +30,7 @@ namespace YooAsset.Editor
public int BuildVersion;
/// <summary>
/// 内置资源的标记列表
/// 内置资源标签集合(首包资源标签)
/// 注意:分号为分隔符
/// </summary>
public string BuildinTags;
@ -51,6 +51,11 @@ namespace YooAsset.Editor
/// </summary>
public bool AppendFileExtension = false;
/// <summary>
/// 拷贝内置资源文件(首包资源文件)
/// </summary>
public bool CopyBuildinTagFiles = false;
/// <summary>
/// 加密类
@ -74,7 +79,7 @@ namespace YooAsset.Editor
/// <summary>
/// 获取内置标记列表
/// 获取内置资源标签列表(首包资源标签)
/// </summary>
public List<string> GetBuildinTags()
{

View File

@ -53,6 +53,11 @@ namespace YooAsset.Editor
/// </summary>
public bool AppendFileExtension;
/// <summary>
/// 拷贝内置资源文件
/// </summary>
public bool CopyBuildinTagFiles;
/// <summary>
/// 自动收集着色器
/// </summary>

View File

@ -13,7 +13,7 @@ namespace YooAsset.Editor
{
// 注意:我们只有在强制重建的时候才会拷贝
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
if (buildParameters.Parameters.BuildMode == EBuildMode.ForceRebuild)
if (buildParameters.Parameters.CopyBuildinTagFiles)
{
// 清空流目录
AssetBundleBuilderHelper.ClearStreamingAssetsFolder();

View File

@ -58,9 +58,7 @@ namespace YooAsset.Editor
{
List<PatchBundle> result = new List<PatchBundle>(1000);
// 内置标记列表
List<string> buildinTags = buildParameters.Parameters.GetBuildinTags();
var buildMode = buildParameters.Parameters.BuildMode;
bool standardBuild = buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild;
foreach (var bundleInfo in buildMapContext.BundleInfos)
@ -90,7 +88,7 @@ namespace YooAsset.Editor
}
private bool IsBuildinBundle(string[] bundleTags, List<string> buildinTags)
{
// 注意:没有任何标记的Bundle文件默认为内置文件
// 注意:没有任何分类标签的Bundle文件默认为内置文件
if (bundleTags.Length == 0)
return true;

View File

@ -42,6 +42,7 @@ namespace YooAsset.Editor
buildReport.Summary.BuildinTags = buildParameters.Parameters.BuildinTags;
buildReport.Summary.EnableAddressable = buildParameters.Parameters.EnableAddressable;
buildReport.Summary.AppendFileExtension = buildParameters.Parameters.AppendFileExtension;
buildReport.Summary.CopyBuildinTagFiles = buildParameters.Parameters.CopyBuildinTagFiles;
buildReport.Summary.AutoCollectShaders = AssetBundleCollectorSettingData.Setting.AutoCollectShaders;
buildReport.Summary.ShadersBundleName = AssetBundleCollectorSettingData.Setting.ShadersBundleName;
buildReport.Summary.EncryptionServicesClassName = buildParameters.Parameters.EncryptionServices == null ?

View File

@ -70,6 +70,7 @@ namespace YooAsset.Editor
_items.Add(new ItemWrapper("启用可寻址资源定位", $"{buildReport.Summary.EnableAddressable}"));
_items.Add(new ItemWrapper("追加文件扩展名", $"{buildReport.Summary.AppendFileExtension}"));
_items.Add(new ItemWrapper("拷贝内置资源文件", $"{buildReport.Summary.CopyBuildinTagFiles}"));
_items.Add(new ItemWrapper("自动收集着色器", $"{buildReport.Summary.AutoCollectShaders}"));
_items.Add(new ItemWrapper("着色器资源包名称", $"{buildReport.Summary.ShadersBundleName}"));
_items.Add(new ItemWrapper("加密服务类名称", $"{buildReport.Summary.EncryptionServicesClassName}"));