This commit is contained in:
何冠峰
2024-12-16 16:45:05 +08:00
parent f0ed677d86
commit 1638bb301d
55 changed files with 496 additions and 351 deletions
@@ -18,7 +18,7 @@ namespace YooAsset.Editor
/// <summary>
/// 创建补丁清单文件到输出目录
/// </summary>
protected void CreateManifestFile(BuildContext context)
protected void CreateManifestFile(bool processBundleDepends, bool processBundleTags, BuildContext context)
{
var buildMapContext = context.GetContextObject<BuildMapContext>();
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
@@ -42,14 +42,13 @@ namespace YooAsset.Editor
manifest.BundleList = GetAllPackageBundle(buildMapContext);
manifest.AssetList = GetAllPackageAsset(buildMapContext);
if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
{
// 处理资源包的依赖列表
// 处理资源包的依赖列表
if (processBundleDepends)
ProcessBundleDepends(context, manifest);
// 处理资源包的标签集合
// 处理资源包的标签集合
if (processBundleTags)
ProcessBundleTags(manifest);
}
// 创建补丁清单文本文件
{
@@ -12,7 +12,7 @@ namespace YooAsset.Editor
/// <summary>
/// 生成资源构建上下文
/// </summary>
public BuildMapContext CreateBuildMap(BuildParameters buildParameters)
public BuildMapContext CreateBuildMap(bool simulateBuild, BuildParameters buildParameters)
{
BuildMapContext context = new BuildMapContext();
var buildMode = buildParameters.BuildMode;
@@ -21,7 +21,7 @@ namespace YooAsset.Editor
Dictionary<string, BuildAssetInfo> allBuildAssetInfos = new Dictionary<string, BuildAssetInfo>(1000);
// 1. 获取所有收集器收集的资源
var collectResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(buildMode, packageName);
var collectResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(simulateBuild, packageName);
List<CollectAssetInfo> allCollectAssets = collectResult.CollectAssets;
// 2. 剔除未被引用的依赖项资源
@@ -65,32 +65,5 @@ namespace YooAsset.Editor
protected abstract string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
protected abstract string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
protected abstract long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
protected string GetFilePathTempHash(string filePath)
{
byte[] bytes = Encoding.UTF8.GetBytes(filePath);
return HashUtility.BytesMD5(bytes);
// 注意:在文件路径的哈希值冲突的情况下,可以使用下面的方法
//return $"{HashUtility.BytesMD5(bytes)}-{Guid.NewGuid():N}";
}
protected long GetBundleTempSize(BuildBundleInfo bundleInfo)
{
long tempSize = 0;
var assetPaths = bundleInfo.GetAllMainAssetPaths();
foreach (var assetPath in assetPaths)
{
long size = FileUtility.GetFileSize(assetPath);
tempSize += size;
}
if (tempSize == 0)
{
string message = BuildLogger.GetErrorMessage(ErrorCode.BundleTempSizeIsZero, $"Bundle temp size is zero, check bundle main asset list : {bundleInfo.BundleName}");
throw new Exception(message);
}
return tempSize;
}
}
}