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.EnableAddressable = buildParameters.Parameters.EnableAddressable;
patchManifest.ResourceVersion = buildParameters.Parameters.BuildVersion;
patchManifest.EnableAddressable = buildParameters.Parameters.EnableAddressable;
patchManifest.OutputNameStyle = (int)buildParameters.Parameters.OutputNameStyle;
patchManifest.BuildinTags = buildParameters.Parameters.BuildinTags;
patchManifest.BundleList = GetAllPatchBundle(buildParameters, buildMapContext, encryptionContext);
patchManifest.AssetList = GetAllPatchAsset(buildParameters, buildMapContext, patchManifest);
@ -69,7 +70,6 @@ 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)
{
@ -83,7 +83,7 @@ namespace YooAsset.Editor
bool isBuildin = IsBuildinBundle(tags, buildinTags);
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);
result.Add(patchBundle);
}

View File

@ -26,11 +26,6 @@ namespace YooAsset
/// </summary>
public long SizeBytes;
/// <summary>
/// 名字样式
/// </summary>
public byte NameStyle;
/// <summary>
/// 资源包的分类标签
/// </summary>
@ -60,52 +55,15 @@ namespace YooAsset
/// <summary>
/// 文件名称
/// </summary>
public string FileName
{
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 string FileName { private set; get; }
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;
Hash = hash;
CRC = crc;
SizeBytes = sizeBytes;
NameStyle = nameStyle;
Tags = tags;
}
@ -136,6 +94,38 @@ namespace YooAsset
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>
/// 是否包含Tag
/// </summary>

View File

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