Update patch manifest

pull/28/head
hevinci 2022-07-25 16:12:34 +08:00
parent 7881f39b97
commit c96fa23d61
3 changed files with 45 additions and 49 deletions

View File

@ -28,8 +28,9 @@ namespace YooAsset.Editor
// 创建新补丁清单 // 创建新补丁清单
PatchManifest patchManifest = new PatchManifest(); PatchManifest patchManifest = new PatchManifest();
patchManifest.EnableAddressable = buildParameters.Parameters.EnableAddressable;
patchManifest.ResourceVersion = buildParameters.Parameters.BuildVersion; patchManifest.ResourceVersion = buildParameters.Parameters.BuildVersion;
patchManifest.EnableAddressable = buildParameters.Parameters.EnableAddressable;
patchManifest.OutputNameStyle = (int)buildParameters.Parameters.OutputNameStyle;
patchManifest.BuildinTags = buildParameters.Parameters.BuildinTags; patchManifest.BuildinTags = buildParameters.Parameters.BuildinTags;
patchManifest.BundleList = GetAllPatchBundle(buildParameters, buildMapContext, encryptionContext); patchManifest.BundleList = GetAllPatchBundle(buildParameters, buildMapContext, encryptionContext);
patchManifest.AssetList = GetAllPatchAsset(buildParameters, buildMapContext, patchManifest); patchManifest.AssetList = GetAllPatchAsset(buildParameters, buildMapContext, patchManifest);
@ -69,7 +70,6 @@ namespace YooAsset.Editor
List<string> buildinTags = buildParameters.Parameters.GetBuildinTags(); List<string> buildinTags = buildParameters.Parameters.GetBuildinTags();
var buildMode = buildParameters.Parameters.BuildMode; var buildMode = buildParameters.Parameters.BuildMode;
var outputNameStype = buildParameters.Parameters.OutputNameStyle;
bool standardBuild = buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild; bool standardBuild = buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild;
foreach (var bundleInfo in buildMapContext.BundleInfos) foreach (var bundleInfo in buildMapContext.BundleInfos)
{ {
@ -83,7 +83,7 @@ namespace YooAsset.Editor
bool isBuildin = IsBuildinBundle(tags, buildinTags); bool isBuildin = IsBuildinBundle(tags, buildinTags);
bool isRawFile = bundleInfo.IsRawFile; bool isRawFile = bundleInfo.IsRawFile;
PatchBundle patchBundle = new PatchBundle(bundleName, hash, crc32, size, (byte)outputNameStype, tags); PatchBundle patchBundle = new PatchBundle(bundleName, hash, crc32, size, tags);
patchBundle.SetFlagsValue(isEncrypted, isBuildin, isRawFile); patchBundle.SetFlagsValue(isEncrypted, isBuildin, isRawFile);
result.Add(patchBundle); result.Add(patchBundle);
} }

View File

@ -26,11 +26,6 @@ namespace YooAsset
/// </summary> /// </summary>
public long SizeBytes; public long SizeBytes;
/// <summary>
/// 名字样式
/// </summary>
public byte NameStyle;
/// <summary> /// <summary>
/// 资源包的分类标签 /// 资源包的分类标签
/// </summary> /// </summary>
@ -60,52 +55,15 @@ namespace YooAsset
/// <summary> /// <summary>
/// 文件名称 /// 文件名称
/// </summary> /// </summary>
public string FileName public string FileName { private set; get; }
{
get
{
if (_fileName != null)
return _fileName;
if (NameStyle == 1)
{
_fileName = Hash;
}
else if (NameStyle == 2)
{
string tempFileExtension = System.IO.Path.GetExtension(BundleName);
_fileName = $"{Hash}{tempFileExtension}";
}
else if (NameStyle == 3)
{
string tempFileExtension = System.IO.Path.GetExtension(BundleName);
string tempBundleName = BundleName.Replace('/', '_').Replace(tempFileExtension, "");
_fileName = $"{tempBundleName}_{Hash}";
}
else if (NameStyle == 4)
{
string tempFileExtension = System.IO.Path.GetExtension(BundleName);
string tempBundleName = BundleName.Replace('/', '_').Replace(tempFileExtension, "");
_fileName = $"{tempBundleName}_{Hash}{tempFileExtension}";
}
else
{
throw new NotImplementedException();
}
return _fileName;
}
}
private string _fileName = null;
public PatchBundle(string bundleName, string hash, string crc, long sizeBytes, byte nameStyle, string[] tags) public PatchBundle(string bundleName, string hash, string crc, long sizeBytes, string[] tags)
{ {
BundleName = bundleName; BundleName = bundleName;
Hash = hash; Hash = hash;
CRC = crc; CRC = crc;
SizeBytes = sizeBytes; SizeBytes = sizeBytes;
NameStyle = nameStyle;
Tags = tags; Tags = tags;
} }
@ -136,6 +94,38 @@ namespace YooAsset
IsRawFile = value.Test(2); IsRawFile = value.Test(2);
} }
/// <summary>
/// 解析文件名称
/// </summary>
public void ParseFileName(int nameStype)
{
if (nameStype == 1)
{
FileName = Hash;
}
else if (nameStype == 2)
{
string tempFileExtension = System.IO.Path.GetExtension(BundleName);
FileName = $"{Hash}{tempFileExtension}";
}
else if (nameStype == 3)
{
string tempFileExtension = System.IO.Path.GetExtension(BundleName);
string tempBundleName = BundleName.Replace('/', '_').Replace(tempFileExtension, "");
FileName = $"{tempBundleName}_{Hash}";
}
else if (nameStype == 4)
{
string tempFileExtension = System.IO.Path.GetExtension(BundleName);
string tempBundleName = BundleName.Replace('/', '_').Replace(tempFileExtension, "");
FileName = $"{tempBundleName}_{Hash}{tempFileExtension}";
}
else
{
throw new NotImplementedException();
}
}
/// <summary> /// <summary>
/// 是否包含Tag /// 是否包含Tag
/// </summary> /// </summary>

View File

@ -12,15 +12,20 @@ namespace YooAsset
[Serializable] [Serializable]
internal class PatchManifest internal class PatchManifest
{ {
/// <summary>
/// 资源版本号
/// </summary>
public int ResourceVersion;
/// <summary> /// <summary>
/// 启用可寻址资源定位 /// 启用可寻址资源定位
/// </summary> /// </summary>
public bool EnableAddressable; public bool EnableAddressable;
/// <summary> /// <summary>
/// 资源版本号 /// 文件名称样式
/// </summary> /// </summary>
public int ResourceVersion; public int OutputNameStyle;
/// <summary> /// <summary>
/// 内置资源的标签列表(首包资源) /// 内置资源的标签列表(首包资源)
@ -228,6 +233,7 @@ namespace YooAsset
foreach (var patchBundle in patchManifest.BundleList) foreach (var patchBundle in patchManifest.BundleList)
{ {
patchBundle.ParseFlagsValue(); patchBundle.ParseFlagsValue();
patchBundle.ParseFileName(patchManifest.OutputNameStyle);
patchManifest.BundleDic.Add(patchBundle.BundleName, patchBundle); patchManifest.BundleDic.Add(patchBundle.BundleName, patchBundle);
} }