Update AssetBundleBuilder
增加输出文件名称样式的选择功能。
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user