pull/418/head
何冠峰 2024-12-13 11:00:30 +08:00
parent 376088e63c
commit 763054884b
2 changed files with 25 additions and 0 deletions

View File

@ -25,6 +25,9 @@ namespace YooAsset.Editor
var buildParameters = buildParametersContext.Parameters;
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
// 检测资源包哈希冲突
CheckBundleHashConflict(buildMapContext);
// 创建新补丁清单
PackageManifest manifest = new PackageManifest();
manifest.FileVersion = YooAssetSettings.ManifestFileVersion;
@ -88,6 +91,27 @@ namespace YooAsset.Editor
}
}
/// <summary>
/// 检测资源包哈希冲突
/// </summary>
private void CheckBundleHashConflict(BuildMapContext buildMapContext)
{
// 说明:在特殊情况下,例如某些文件加密算法会导致加密后的文件哈希值冲突!
HashSet<string> guids = new HashSet<string>();
foreach (var bundleInfo in buildMapContext.Collection)
{
if (guids.Contains(bundleInfo.PackageFileHash))
{
string message = BuildLogger.GetErrorMessage(ErrorCode.BundleHashConflict, $"Bundle hash conflict : {bundleInfo.BundleName}");
throw new Exception(message);
}
else
{
guids.Add(bundleInfo.PackageFileHash);
}
}
}
/// <summary>
/// 获取资源包的依赖集合
/// </summary>

View File

@ -39,5 +39,6 @@ namespace YooAsset.Editor
// TaskCreateManifest
NotFoundUnityBundleInBuildResult = 600,
FoundStrayBundle = 601,
BundleHashConflict = 602,
}
}