mirror of https://github.com/tuyoogame/YooAsset
parent
6d392139df
commit
42d52720f3
|
@ -30,14 +30,14 @@ namespace YooAsset.Editor
|
|||
/// </summary>
|
||||
public ECompressOption CompressOption = ECompressOption.LZ4;
|
||||
|
||||
/// <summary>
|
||||
/// 输出文件名称样式
|
||||
/// </summary>
|
||||
public EOutputNameStyle OutputNameStyle = EOutputNameStyle.HashName;
|
||||
|
||||
/// <summary>
|
||||
/// 加密类名称
|
||||
/// </summary>
|
||||
public string EncyptionClassName = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 附加后缀格式
|
||||
/// </summary>
|
||||
public bool AppendExtension = false;
|
||||
}
|
||||
}
|
|
@ -30,7 +30,7 @@ namespace YooAsset.Editor
|
|||
private TextField _buildinTagsField;
|
||||
private PopupField<string> _encryptionField;
|
||||
private EnumField _compressionField;
|
||||
private Toggle _appendExtensionToggle;
|
||||
private EnumField _outputNameStyleField;
|
||||
|
||||
public void CreateGUI()
|
||||
{
|
||||
|
@ -76,7 +76,7 @@ namespace YooAsset.Editor
|
|||
_buildPipelineField = root.Q<EnumField>("BuildPipeline");
|
||||
_buildPipelineField.Init(AssetBundleBuilderSettingData.Setting.BuildPipeline);
|
||||
_buildPipelineField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.BuildPipeline);
|
||||
_buildPipelineField.style.width = 300;
|
||||
_buildPipelineField.style.width = 350;
|
||||
_buildPipelineField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSettingData.IsDirty = true;
|
||||
|
@ -88,7 +88,7 @@ namespace YooAsset.Editor
|
|||
_buildModeField = root.Q<EnumField>("BuildMode");
|
||||
_buildModeField.Init(AssetBundleBuilderSettingData.Setting.BuildMode);
|
||||
_buildModeField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.BuildMode);
|
||||
_buildModeField.style.width = 300;
|
||||
_buildModeField.style.width = 350;
|
||||
_buildModeField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSettingData.IsDirty = true;
|
||||
|
@ -112,7 +112,7 @@ namespace YooAsset.Editor
|
|||
int defaultIndex = GetEncryptionDefaultIndex(AssetBundleBuilderSettingData.Setting.EncyptionClassName);
|
||||
_encryptionField = new PopupField<string>(_encryptionServicesClassNames, defaultIndex);
|
||||
_encryptionField.label = "Encryption";
|
||||
_encryptionField.style.width = 300;
|
||||
_encryptionField.style.width = 350;
|
||||
_encryptionField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSettingData.IsDirty = true;
|
||||
|
@ -124,7 +124,7 @@ namespace YooAsset.Editor
|
|||
{
|
||||
_encryptionField = new PopupField<string>();
|
||||
_encryptionField.label = "Encryption";
|
||||
_encryptionField.style.width = 300;
|
||||
_encryptionField.style.width = 350;
|
||||
encryptionContainer.Add(_encryptionField);
|
||||
}
|
||||
|
||||
|
@ -132,20 +132,22 @@ namespace YooAsset.Editor
|
|||
_compressionField = root.Q<EnumField>("Compression");
|
||||
_compressionField.Init(AssetBundleBuilderSettingData.Setting.CompressOption);
|
||||
_compressionField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.CompressOption);
|
||||
_compressionField.style.width = 300;
|
||||
_compressionField.style.width = 350;
|
||||
_compressionField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSettingData.IsDirty = true;
|
||||
AssetBundleBuilderSettingData.Setting.CompressOption = (ECompressOption)_compressionField.value;
|
||||
});
|
||||
|
||||
// 附加后缀格式
|
||||
_appendExtensionToggle = root.Q<Toggle>("AppendExtension");
|
||||
_appendExtensionToggle.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.AppendExtension);
|
||||
_appendExtensionToggle.RegisterValueChangedCallback(evt =>
|
||||
// 输出文件名称样式
|
||||
_outputNameStyleField = root.Q<EnumField>("OutputNameStyle");
|
||||
_outputNameStyleField.Init(AssetBundleBuilderSettingData.Setting.OutputNameStyle);
|
||||
_outputNameStyleField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.OutputNameStyle);
|
||||
_outputNameStyleField.style.width = 350;
|
||||
_outputNameStyleField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSettingData.IsDirty = true;
|
||||
AssetBundleBuilderSettingData.Setting.AppendExtension = _appendExtensionToggle.value;
|
||||
AssetBundleBuilderSettingData.Setting.OutputNameStyle = (EOutputNameStyle)_outputNameStyleField.value;
|
||||
});
|
||||
|
||||
// 构建按钮
|
||||
|
@ -188,7 +190,7 @@ namespace YooAsset.Editor
|
|||
_buildinTagsField.SetEnabled(enableElement);
|
||||
_encryptionField.SetEnabled(enableElement);
|
||||
_compressionField.SetEnabled(enableElement);
|
||||
_appendExtensionToggle.SetEnabled(enableElement);
|
||||
_outputNameStyleField.SetEnabled(enableElement);
|
||||
}
|
||||
private void SaveBtn_clicked()
|
||||
{
|
||||
|
@ -223,10 +225,10 @@ namespace YooAsset.Editor
|
|||
buildParameters.BuildinTags = AssetBundleBuilderSettingData.Setting.BuildTags;
|
||||
buildParameters.VerifyBuildingResult = true;
|
||||
buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
|
||||
buildParameters.AppendFileExtension = AssetBundleBuilderSettingData.Setting.AppendExtension;
|
||||
buildParameters.CopyBuildinTagFiles = AssetBundleBuilderSettingData.Setting.BuildMode == EBuildMode.ForceRebuild;
|
||||
buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
|
||||
buildParameters.CompressOption = AssetBundleBuilderSettingData.Setting.CompressOption;
|
||||
buildParameters.OutputNameStyle = AssetBundleBuilderSettingData.Setting.OutputNameStyle;
|
||||
|
||||
if (AssetBundleBuilderSettingData.Setting.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
||||
{
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<uie:EnumField label="Build Mode" name="BuildMode" />
|
||||
<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;" />
|
||||
<uie:EnumField label="Output Name Style" value="Center" name="OutputNameStyle" />
|
||||
<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>
|
||||
|
|
|
@ -78,11 +78,6 @@ namespace YooAsset.Editor
|
|||
/// </summary>
|
||||
public bool EnableAddressable = false;
|
||||
|
||||
/// <summary>
|
||||
/// 追加文件扩展名
|
||||
/// </summary>
|
||||
public bool AppendFileExtension = false;
|
||||
|
||||
/// <summary>
|
||||
/// 拷贝内置资源文件到StreamingAssets目录(首包资源文件)
|
||||
/// </summary>
|
||||
|
@ -94,6 +89,11 @@ namespace YooAsset.Editor
|
|||
/// </summary>
|
||||
public IEncryptionServices EncryptionServices = null;
|
||||
|
||||
/// <summary>
|
||||
/// 补丁文件名称的样式
|
||||
/// </summary>
|
||||
public EOutputNameStyle OutputNameStyle = EOutputNameStyle.HashName;
|
||||
|
||||
/// <summary>
|
||||
/// 压缩选项
|
||||
/// </summary>
|
||||
|
|
|
@ -58,11 +58,6 @@ namespace YooAsset.Editor
|
|||
/// </summary>
|
||||
public bool EnableAddressable;
|
||||
|
||||
/// <summary>
|
||||
/// 追加文件扩展名
|
||||
/// </summary>
|
||||
public bool AppendFileExtension;
|
||||
|
||||
/// <summary>
|
||||
/// 拷贝内置资源文件
|
||||
/// </summary>
|
||||
|
@ -84,6 +79,7 @@ namespace YooAsset.Editor
|
|||
public string EncryptionServicesClassName;
|
||||
|
||||
// 构建参数
|
||||
public EOutputNameStyle OutputNameStyle;
|
||||
public ECompressOption CompressOption;
|
||||
public bool DisableWriteTypeTree;
|
||||
public bool IgnoreTypeTreeChanges;
|
||||
|
|
|
@ -69,6 +69,7 @@ namespace YooAsset.Editor
|
|||
|
||||
List<string> buildinTags = buildParameters.Parameters.GetBuildinTags();
|
||||
var buildMode = buildParameters.Parameters.BuildMode;
|
||||
var outputNameStype = buildParameters.Parameters.OutputNameStyle;
|
||||
bool standardBuild = buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild;
|
||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
||||
{
|
||||
|
@ -82,13 +83,8 @@ namespace YooAsset.Editor
|
|||
bool isBuildin = IsBuildinBundle(tags, buildinTags);
|
||||
bool isRawFile = bundleInfo.IsRawFile;
|
||||
|
||||
// 附加文件扩展名
|
||||
if (buildParameters.Parameters.AppendFileExtension)
|
||||
{
|
||||
hash += bundleInfo.GetAppendExtension();
|
||||
}
|
||||
|
||||
PatchBundle patchBundle = new PatchBundle(bundleName, hash, crc32, size, tags);
|
||||
string fileName = GetFileOutputName(outputNameStype, hash, bundleInfo);
|
||||
PatchBundle patchBundle = new PatchBundle(bundleName, fileName, crc32, size, tags);
|
||||
patchBundle.SetFlagsValue(isEncrypted, isBuildin, isRawFile);
|
||||
result.Add(patchBundle);
|
||||
}
|
||||
|
@ -108,6 +104,37 @@ namespace YooAsset.Editor
|
|||
}
|
||||
return false;
|
||||
}
|
||||
private string GetFileOutputName(EOutputNameStyle outputNameStyle, string hash, BuildBundleInfo bundleInfo)
|
||||
{
|
||||
string fileName;
|
||||
var bundleName = bundleInfo.BundleName;
|
||||
if (outputNameStyle == EOutputNameStyle.HashName)
|
||||
{
|
||||
fileName = hash;
|
||||
}
|
||||
else if (outputNameStyle == EOutputNameStyle.HashName_Extension)
|
||||
{
|
||||
string tempFileExtension = bundleInfo.GetAppendExtension();
|
||||
fileName = $"{hash}{tempFileExtension}";
|
||||
}
|
||||
else if (outputNameStyle == EOutputNameStyle.BundleName_HashName)
|
||||
{
|
||||
string tempFileExtension = bundleInfo.GetAppendExtension();
|
||||
string tempBundleName = bundleName.Replace('/', '_').Replace(tempFileExtension, "");
|
||||
fileName = $"{tempBundleName}_{hash}";
|
||||
}
|
||||
else if (outputNameStyle == EOutputNameStyle.BundleName_HashName_Extension)
|
||||
{
|
||||
string tempFileExtension = bundleInfo.GetAppendExtension();
|
||||
string tempBundleName = bundleName.Replace('/', '_').Replace(tempFileExtension, "");
|
||||
fileName = $"{tempBundleName}_{hash}{tempFileExtension}";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
return fileName;
|
||||
}
|
||||
private string GetFileHash(string filePath, bool standardBuild)
|
||||
{
|
||||
if (standardBuild)
|
||||
|
|
|
@ -47,7 +47,6 @@ namespace YooAsset.Editor
|
|||
buildReport.Summary.BuildVersion = buildParameters.Parameters.BuildVersion;
|
||||
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;
|
||||
|
@ -55,6 +54,7 @@ namespace YooAsset.Editor
|
|||
"null" : buildParameters.Parameters.EncryptionServices.GetType().FullName;
|
||||
|
||||
// 构建参数
|
||||
buildReport.Summary.OutputNameStyle = buildParameters.Parameters.OutputNameStyle;
|
||||
buildReport.Summary.CompressOption = buildParameters.Parameters.CompressOption;
|
||||
buildReport.Summary.DisableWriteTypeTree = buildParameters.Parameters.DisableWriteTypeTree;
|
||||
buildReport.Summary.IgnoreTypeTreeChanges = buildParameters.Parameters.IgnoreTypeTreeChanges;
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 输出文件名称的样式
|
||||
/// </summary>
|
||||
public enum EOutputNameStyle
|
||||
{
|
||||
/// <summary>
|
||||
/// 000000000000000f000000000000000
|
||||
/// </summary>
|
||||
HashName,
|
||||
|
||||
/// <summary>
|
||||
/// 000000000000000f000000000000000.bundle
|
||||
/// </summary>
|
||||
HashName_Extension,
|
||||
|
||||
/// <summary>
|
||||
/// bundle_name_000000000000000f000000000000000
|
||||
/// </summary>
|
||||
BundleName_HashName,
|
||||
|
||||
/// <summary>
|
||||
/// bundle_name_000000000000000f000000000000000.bundle
|
||||
/// </summary>
|
||||
BundleName_HashName_Extension,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 84c5eff5dedf53343897e83f6b10eea6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -70,7 +70,6 @@ namespace YooAsset.Editor
|
|||
_items.Add(new ItemWrapper("内置资源标签", $"{buildReport.Summary.BuildinTags}"));
|
||||
|
||||
_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}"));
|
||||
|
@ -78,6 +77,7 @@ namespace YooAsset.Editor
|
|||
|
||||
_items.Add(new ItemWrapper(string.Empty, string.Empty));
|
||||
_items.Add(new ItemWrapper("构建参数", string.Empty));
|
||||
_items.Add(new ItemWrapper("OutputNameStyle", $"{buildReport.Summary.OutputNameStyle}"));
|
||||
_items.Add(new ItemWrapper("CompressOption", $"{buildReport.Summary.CompressOption}"));
|
||||
_items.Add(new ItemWrapper("DisableWriteTypeTree", $"{buildReport.Summary.DisableWriteTypeTree}"));
|
||||
_items.Add(new ItemWrapper("IgnoreTypeTreeChanges", $"{buildReport.Summary.IgnoreTypeTreeChanges}"));
|
||||
|
|
Loading…
Reference in New Issue