update editor code
parent
9c05ac8cc2
commit
10e04c7645
|
@ -51,10 +51,10 @@ namespace YooAsset.Editor
|
||||||
new TaskCopyRawFile(), //拷贝原生文件
|
new TaskCopyRawFile(), //拷贝原生文件
|
||||||
new TaskVerifyBuildResult(), //验证构建结果
|
new TaskVerifyBuildResult(), //验证构建结果
|
||||||
new TaskEncryption(), //加密资源文件
|
new TaskEncryption(), //加密资源文件
|
||||||
new TaskUpdatePatchInfo(), //更新补丁信息
|
new TaskUpdateBundleInfo(), //更新资源包信息
|
||||||
new TaskCreatePatchManifest(), //创建清单文件
|
new TaskCreateManifest(), //创建清单文件
|
||||||
new TaskCreateReport(), //创建报告文件
|
new TaskCreateReport(), //创建报告文件
|
||||||
new TaskCreatePatchPackage(), //制作补丁包
|
new TaskCreatePackage(), //制作包裹
|
||||||
new TaskCopyBuildinFiles(), //拷贝内置文件
|
new TaskCopyBuildinFiles(), //拷贝内置文件
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -68,10 +68,10 @@ namespace YooAsset.Editor
|
||||||
new TaskCopyRawFile(), //拷贝原生文件
|
new TaskCopyRawFile(), //拷贝原生文件
|
||||||
new TaskVerifyBuildResult_SBP(), //验证构建结果
|
new TaskVerifyBuildResult_SBP(), //验证构建结果
|
||||||
new TaskEncryption(), //加密资源文件
|
new TaskEncryption(), //加密资源文件
|
||||||
new TaskUpdatePatchInfo(), //更新补丁信息
|
new TaskUpdateBundleInfo(), //更新补丁信息
|
||||||
new TaskCreatePatchManifest(), //创建清单文件
|
new TaskCreateManifest(), //创建清单文件
|
||||||
new TaskCreateReport(), //创建报告文件
|
new TaskCreateReport(), //创建报告文件
|
||||||
new TaskCreatePatchPackage(), //制作补丁包
|
new TaskCreatePackage(), //制作补丁包
|
||||||
new TaskCopyBuildinFiles(), //拷贝内置文件
|
new TaskCopyBuildinFiles(), //拷贝内置文件
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class BuildBundleInfo
|
public class BuildBundleInfo
|
||||||
{
|
{
|
||||||
public class BuildPatchInfo
|
public class InfoWrapper
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建内容的哈希值
|
/// 构建内容的哈希值
|
||||||
|
@ -18,17 +18,17 @@ namespace YooAsset.Editor
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件哈希值
|
/// 文件哈希值
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string PatchFileHash { set; get; }
|
public string FileHash { set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件哈希值
|
/// 文件哈希值
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string PatchFileCRC { set; get; }
|
public string FileCRC { set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件哈希值
|
/// 文件哈希值
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long PatchFileSize { set; get; }
|
public long FileSize { set; get; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -39,7 +39,7 @@ namespace YooAsset.Editor
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 补丁包输出文件路径
|
/// 补丁包输出文件路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string PatchOutputFilePath { set; get; }
|
public string PackageOutputFilePath { set; get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -56,7 +56,7 @@ namespace YooAsset.Editor
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 补丁文件信息
|
/// 补丁文件信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly BuildPatchInfo PatchInfo = new BuildPatchInfo();
|
public readonly InfoWrapper BundleInfo = new InfoWrapper();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Bundle文件的加载方法
|
/// Bundle文件的加载方法
|
||||||
|
@ -159,7 +159,7 @@ namespace YooAsset.Editor
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取所有写入补丁清单的资源
|
/// 获取所有写入补丁清单的资源
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BuildAssetInfo[] GetAllPatchAssetInfos()
|
public BuildAssetInfo[] GetAllBuildAssetInfos()
|
||||||
{
|
{
|
||||||
return BuildinAssets.Where(t => t.CollectorType == ECollectorType.MainAssetCollector).ToArray();
|
return BuildinAssets.Where(t => t.CollectorType == ECollectorType.MainAssetCollector).ToArray();
|
||||||
}
|
}
|
||||||
|
@ -178,19 +178,19 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建PatchBundle类
|
/// 创建PackageBundle类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal PatchBundle CreatePatchBundle()
|
internal PackageBundle CreatePackageBundle()
|
||||||
{
|
{
|
||||||
PatchBundle patchBundle = new PatchBundle();
|
PackageBundle packageBundle = new PackageBundle();
|
||||||
patchBundle.BundleName = BundleName;
|
packageBundle.BundleName = BundleName;
|
||||||
patchBundle.FileHash = PatchInfo.PatchFileHash;
|
packageBundle.FileHash = BundleInfo.FileHash;
|
||||||
patchBundle.FileCRC = PatchInfo.PatchFileCRC;
|
packageBundle.FileCRC = BundleInfo.FileCRC;
|
||||||
patchBundle.FileSize = PatchInfo.PatchFileSize;
|
packageBundle.FileSize = BundleInfo.FileSize;
|
||||||
patchBundle.IsRawFile = IsRawFile;
|
packageBundle.IsRawFile = IsRawFile;
|
||||||
patchBundle.LoadMethod = (byte)LoadMethod;
|
packageBundle.LoadMethod = (byte)LoadMethod;
|
||||||
patchBundle.Tags = GetBundleTags();
|
packageBundle.Tags = GetBundleTags();
|
||||||
return patchBundle;
|
return packageBundle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -12,13 +12,13 @@ namespace YooAsset.Editor
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var patchManifestContext = context.GetContextObject<PatchManifestContext>();
|
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||||
{
|
{
|
||||||
if (buildParametersContext.Parameters.CopyBuildinFileOption != ECopyBuildinFileOption.None)
|
if (buildParametersContext.Parameters.CopyBuildinFileOption != ECopyBuildinFileOption.None)
|
||||||
{
|
{
|
||||||
CopyBuildinFilesToStreaming(buildParametersContext, patchManifestContext);
|
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ namespace YooAsset.Editor
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 拷贝首包资源文件
|
/// 拷贝首包资源文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void CopyBuildinFilesToStreaming(BuildParametersContext buildParametersContext, PatchManifestContext patchManifestContext)
|
private void CopyBuildinFilesToStreaming(BuildParametersContext buildParametersContext, ManifestContext manifestContext)
|
||||||
{
|
{
|
||||||
ECopyBuildinFileOption option = buildParametersContext.Parameters.CopyBuildinFileOption;
|
ECopyBuildinFileOption option = buildParametersContext.Parameters.CopyBuildinFileOption;
|
||||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||||
|
@ -35,7 +35,7 @@ namespace YooAsset.Editor
|
||||||
string buildPackageVersion = buildParametersContext.Parameters.PackageVersion;
|
string buildPackageVersion = buildParametersContext.Parameters.PackageVersion;
|
||||||
|
|
||||||
// 加载补丁清单
|
// 加载补丁清单
|
||||||
PatchManifest patchManifest = patchManifestContext.Manifest;
|
PackageManifest manifest = manifestContext.Manifest;
|
||||||
|
|
||||||
// 清空流目录
|
// 清空流目录
|
||||||
if (option == ECopyBuildinFileOption.ClearAndCopyAll || option == ECopyBuildinFileOption.ClearAndCopyByTags)
|
if (option == ECopyBuildinFileOption.ClearAndCopyAll || option == ECopyBuildinFileOption.ClearAndCopyByTags)
|
||||||
|
@ -70,10 +70,10 @@ namespace YooAsset.Editor
|
||||||
// 拷贝文件列表(所有文件)
|
// 拷贝文件列表(所有文件)
|
||||||
if (option == ECopyBuildinFileOption.ClearAndCopyAll || option == ECopyBuildinFileOption.OnlyCopyAll)
|
if (option == ECopyBuildinFileOption.ClearAndCopyAll || option == ECopyBuildinFileOption.OnlyCopyAll)
|
||||||
{
|
{
|
||||||
foreach (var patchBundle in patchManifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
string sourcePath = $"{packageOutputDirectory}/{patchBundle.FileName}";
|
string sourcePath = $"{packageOutputDirectory}/{packageBundle.FileName}";
|
||||||
string destPath = $"{streamingAssetsDirectory}/{patchBundle.FileName}";
|
string destPath = $"{streamingAssetsDirectory}/{packageBundle.FileName}";
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,12 +82,12 @@ namespace YooAsset.Editor
|
||||||
if (option == ECopyBuildinFileOption.ClearAndCopyByTags || option == ECopyBuildinFileOption.OnlyCopyByTags)
|
if (option == ECopyBuildinFileOption.ClearAndCopyByTags || option == ECopyBuildinFileOption.OnlyCopyByTags)
|
||||||
{
|
{
|
||||||
string[] tags = buildParametersContext.Parameters.CopyBuildinFileTags.Split(';');
|
string[] tags = buildParametersContext.Parameters.CopyBuildinFileTags.Split(';');
|
||||||
foreach (var patchBundle in patchManifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
if (patchBundle.HasTag(tags) == false)
|
if (packageBundle.HasTag(tags) == false)
|
||||||
continue;
|
continue;
|
||||||
string sourcePath = $"{packageOutputDirectory}/{patchBundle.FileName}";
|
string sourcePath = $"{packageOutputDirectory}/{packageBundle.FileName}";
|
||||||
string destPath = $"{streamingAssetsDirectory}/{patchBundle.FileName}";
|
string destPath = $"{streamingAssetsDirectory}/{packageBundle.FileName}";
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,23 +8,23 @@ using UnityEditor.Build.Pipeline.Interfaces;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class PatchManifestContext : IContextObject
|
public class ManifestContext : IContextObject
|
||||||
{
|
{
|
||||||
internal PatchManifest Manifest;
|
internal PackageManifest Manifest;
|
||||||
}
|
}
|
||||||
|
|
||||||
[TaskAttribute("创建补丁清单文件")]
|
[TaskAttribute("创建清单文件")]
|
||||||
public class TaskCreatePatchManifest : IBuildTask
|
public class TaskCreateManifest : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
CreatePatchManifestFile(context);
|
CreateManifestFile(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建补丁清单文件到输出目录
|
/// 创建补丁清单文件到输出目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void CreatePatchManifestFile(BuildContext context)
|
private void CreateManifestFile(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
|
@ -32,14 +32,14 @@ namespace YooAsset.Editor
|
||||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||||
|
|
||||||
// 创建新补丁清单
|
// 创建新补丁清单
|
||||||
PatchManifest patchManifest = new PatchManifest();
|
PackageManifest manifest = new PackageManifest();
|
||||||
patchManifest.FileVersion = YooAssetSettings.PatchManifestFileVersion;
|
manifest.FileVersion = YooAssetSettings.ManifestFileVersion;
|
||||||
patchManifest.EnableAddressable = buildMapContext.EnableAddressable;
|
manifest.EnableAddressable = buildMapContext.EnableAddressable;
|
||||||
patchManifest.OutputNameStyle = (int)buildParameters.OutputNameStyle;
|
manifest.OutputNameStyle = (int)buildParameters.OutputNameStyle;
|
||||||
patchManifest.PackageName = buildParameters.PackageName;
|
manifest.PackageName = buildParameters.PackageName;
|
||||||
patchManifest.PackageVersion = buildParameters.PackageVersion;
|
manifest.PackageVersion = buildParameters.PackageVersion;
|
||||||
patchManifest.BundleList = GetAllPatchBundle(context);
|
manifest.BundleList = GetAllPackageBundle(context);
|
||||||
patchManifest.AssetList = GetAllPatchAsset(context, patchManifest);
|
manifest.AssetList = GetAllPackageAsset(context, manifest);
|
||||||
|
|
||||||
// 更新Unity内置资源包的引用关系
|
// 更新Unity内置资源包的引用关系
|
||||||
if (buildParameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
if (buildParameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
||||||
|
@ -47,7 +47,7 @@ namespace YooAsset.Editor
|
||||||
if (buildParameters.BuildMode == EBuildMode.IncrementalBuild)
|
if (buildParameters.BuildMode == EBuildMode.IncrementalBuild)
|
||||||
{
|
{
|
||||||
var buildResultContext = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
var buildResultContext = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
||||||
UpdateBuiltInBundleReference(patchManifest, buildResultContext, buildMapContext.ShadersBundleName);
|
UpdateBuiltInBundleReference(manifest, buildResultContext, buildMapContext.ShadersBundleName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ namespace YooAsset.Editor
|
||||||
if (buildParameters.BuildMode == EBuildMode.IncrementalBuild)
|
if (buildParameters.BuildMode == EBuildMode.IncrementalBuild)
|
||||||
{
|
{
|
||||||
var buildResultContext = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
var buildResultContext = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
||||||
UpdateScriptPipelineReference(patchManifest, buildResultContext);
|
UpdateScriptPipelineReference(manifest, buildResultContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ namespace YooAsset.Editor
|
||||||
if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
|
if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
|
||||||
{
|
{
|
||||||
var buildResultContext = context.GetContextObject<TaskBuilding.BuildResultContext>();
|
var buildResultContext = context.GetContextObject<TaskBuilding.BuildResultContext>();
|
||||||
UpdateBuiltinPipelineReference(patchManifest, buildResultContext);
|
UpdateBuiltinPipelineReference(manifest, buildResultContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
string fileName = YooAssetSettingsData.GetManifestJsonFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
string fileName = YooAssetSettingsData.GetManifestJsonFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||||
PatchManifestTools.SerializeToJson(filePath, patchManifest);
|
ManifestTools.SerializeToJson(filePath, manifest);
|
||||||
BuildLogger.Log($"创建补丁清单文件:{filePath}");
|
BuildLogger.Log($"创建补丁清单文件:{filePath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,14 +84,14 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||||
PatchManifestTools.SerializeToBinary(filePath, patchManifest);
|
ManifestTools.SerializeToBinary(filePath, manifest);
|
||||||
packageHash = HashUtility.FileMD5(filePath);
|
packageHash = HashUtility.FileMD5(filePath);
|
||||||
BuildLogger.Log($"创建补丁清单文件:{filePath}");
|
BuildLogger.Log($"创建补丁清单文件:{filePath}");
|
||||||
|
|
||||||
PatchManifestContext patchManifestContext = new PatchManifestContext();
|
ManifestContext manifestContext = new ManifestContext();
|
||||||
byte[] bytesData = FileUtility.ReadAllBytes(filePath);
|
byte[] bytesData = FileUtility.ReadAllBytes(filePath);
|
||||||
patchManifestContext.Manifest = PatchManifestTools.DeserializeFromBinary(bytesData);
|
manifestContext.Manifest = ManifestTools.DeserializeFromBinary(bytesData);
|
||||||
context.SetContextObject(patchManifestContext);
|
context.SetContextObject(manifestContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建补丁清单哈希文件
|
// 创建补丁清单哈希文件
|
||||||
|
@ -114,15 +114,15 @@ namespace YooAsset.Editor
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源包列表
|
/// 获取资源包列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private List<PatchBundle> GetAllPatchBundle(BuildContext context)
|
private List<PackageBundle> GetAllPackageBundle(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
|
|
||||||
List<PatchBundle> result = new List<PatchBundle>(1000);
|
List<PackageBundle> result = new List<PackageBundle>(1000);
|
||||||
foreach (var bundleInfo in buildMapContext.Collection)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
{
|
{
|
||||||
var patchBundle = bundleInfo.CreatePatchBundle();
|
var packageBundle = bundleInfo.CreatePackageBundle();
|
||||||
result.Add(patchBundle);
|
result.Add(packageBundle);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -130,38 +130,38 @@ namespace YooAsset.Editor
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源列表
|
/// 获取资源列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private List<PatchAsset> GetAllPatchAsset(BuildContext context, PatchManifest patchManifest)
|
private List<PackageAsset> GetAllPackageAsset(BuildContext context, PackageManifest manifest)
|
||||||
{
|
{
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
|
|
||||||
List<PatchAsset> result = new List<PatchAsset>(1000);
|
List<PackageAsset> result = new List<PackageAsset>(1000);
|
||||||
foreach (var bundleInfo in buildMapContext.Collection)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
{
|
{
|
||||||
var assetInfos = bundleInfo.GetAllPatchAssetInfos();
|
var assetInfos = bundleInfo.GetAllBuildAssetInfos();
|
||||||
foreach (var assetInfo in assetInfos)
|
foreach (var assetInfo in assetInfos)
|
||||||
{
|
{
|
||||||
PatchAsset patchAsset = new PatchAsset();
|
PackageAsset packageAsset = new PackageAsset();
|
||||||
if (buildMapContext.EnableAddressable)
|
if (buildMapContext.EnableAddressable)
|
||||||
patchAsset.Address = assetInfo.Address;
|
packageAsset.Address = assetInfo.Address;
|
||||||
else
|
else
|
||||||
patchAsset.Address = string.Empty;
|
packageAsset.Address = string.Empty;
|
||||||
patchAsset.AssetPath = assetInfo.AssetPath;
|
packageAsset.AssetPath = assetInfo.AssetPath;
|
||||||
patchAsset.AssetTags = assetInfo.AssetTags.ToArray();
|
packageAsset.AssetTags = assetInfo.AssetTags.ToArray();
|
||||||
patchAsset.BundleID = GetAssetBundleID(assetInfo.BundleName, patchManifest);
|
packageAsset.BundleID = GetAssetBundleID(assetInfo.BundleName, manifest);
|
||||||
patchAsset.DependIDs = GetAssetBundleDependIDs(patchAsset.BundleID, assetInfo, patchManifest);
|
packageAsset.DependIDs = GetAssetBundleDependIDs(packageAsset.BundleID, assetInfo, manifest);
|
||||||
result.Add(patchAsset);
|
result.Add(packageAsset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
private int[] GetAssetBundleDependIDs(int mainBundleID, BuildAssetInfo assetInfo, PatchManifest patchManifest)
|
private int[] GetAssetBundleDependIDs(int mainBundleID, BuildAssetInfo assetInfo, PackageManifest manifest)
|
||||||
{
|
{
|
||||||
List<int> result = new List<int>();
|
List<int> result = new List<int>();
|
||||||
foreach (var dependAssetInfo in assetInfo.AllDependAssetInfos)
|
foreach (var dependAssetInfo in assetInfo.AllDependAssetInfos)
|
||||||
{
|
{
|
||||||
if (dependAssetInfo.HasBundleName())
|
if (dependAssetInfo.HasBundleName())
|
||||||
{
|
{
|
||||||
int bundleID = GetAssetBundleID(dependAssetInfo.BundleName, patchManifest);
|
int bundleID = GetAssetBundleID(dependAssetInfo.BundleName, manifest);
|
||||||
if (mainBundleID != bundleID)
|
if (mainBundleID != bundleID)
|
||||||
{
|
{
|
||||||
if (result.Contains(bundleID) == false)
|
if (result.Contains(bundleID) == false)
|
||||||
|
@ -171,11 +171,11 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
return result.ToArray();
|
return result.ToArray();
|
||||||
}
|
}
|
||||||
private int GetAssetBundleID(string bundleName, PatchManifest patchManifest)
|
private int GetAssetBundleID(string bundleName, PackageManifest manifest)
|
||||||
{
|
{
|
||||||
for (int index = 0; index < patchManifest.BundleList.Count; index++)
|
for (int index = 0; index < manifest.BundleList.Count; index++)
|
||||||
{
|
{
|
||||||
if (patchManifest.BundleList[index].BundleName == bundleName)
|
if (manifest.BundleList[index].BundleName == bundleName)
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
throw new Exception($"Not found bundle name : {bundleName}");
|
throw new Exception($"Not found bundle name : {bundleName}");
|
||||||
|
@ -184,7 +184,7 @@ namespace YooAsset.Editor
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新Unity内置资源包的引用关系
|
/// 更新Unity内置资源包的引用关系
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void UpdateBuiltInBundleReference(PatchManifest patchManifest, TaskBuilding_SBP.BuildResultContext buildResultContext, string shadersBunldeName)
|
private void UpdateBuiltInBundleReference(PackageManifest manifest, TaskBuilding_SBP.BuildResultContext buildResultContext, string shadersBunldeName)
|
||||||
{
|
{
|
||||||
// 获取所有依赖着色器资源包的资源包列表
|
// 获取所有依赖着色器资源包的资源包列表
|
||||||
List<string> shaderBundleReferenceList = new List<string>();
|
List<string> shaderBundleReferenceList = new List<string>();
|
||||||
|
@ -199,33 +199,33 @@ namespace YooAsset.Editor
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// 获取着色器资源包索引
|
// 获取着色器资源包索引
|
||||||
Predicate<PatchBundle> predicate = new Predicate<PatchBundle>(s => s.BundleName == shadersBunldeName);
|
Predicate<PackageBundle> predicate = new Predicate<PackageBundle>(s => s.BundleName == shadersBunldeName);
|
||||||
int shaderBundleId = patchManifest.BundleList.FindIndex(predicate);
|
int shaderBundleId = manifest.BundleList.FindIndex(predicate);
|
||||||
if (shaderBundleId == -1)
|
if (shaderBundleId == -1)
|
||||||
throw new Exception("没有发现着色器资源包!");
|
throw new Exception("没有发现着色器资源包!");
|
||||||
|
|
||||||
// 检测依赖交集并更新依赖ID
|
// 检测依赖交集并更新依赖ID
|
||||||
foreach (var patchAsset in patchManifest.AssetList)
|
foreach (var packageAsset in manifest.AssetList)
|
||||||
{
|
{
|
||||||
List<string> dependBundles = GetPatchAssetAllDependBundles(patchManifest, patchAsset);
|
List<string> dependBundles = GetPackageAssetAllDependBundles(manifest, packageAsset);
|
||||||
List<string> conflictAssetPathList = dependBundles.Intersect(shaderBundleReferenceList).ToList();
|
List<string> conflictAssetPathList = dependBundles.Intersect(shaderBundleReferenceList).ToList();
|
||||||
if (conflictAssetPathList.Count > 0)
|
if (conflictAssetPathList.Count > 0)
|
||||||
{
|
{
|
||||||
List<int> newDependIDs = new List<int>(patchAsset.DependIDs);
|
List<int> newDependIDs = new List<int>(packageAsset.DependIDs);
|
||||||
if (newDependIDs.Contains(shaderBundleId) == false)
|
if (newDependIDs.Contains(shaderBundleId) == false)
|
||||||
newDependIDs.Add(shaderBundleId);
|
newDependIDs.Add(shaderBundleId);
|
||||||
patchAsset.DependIDs = newDependIDs.ToArray();
|
packageAsset.DependIDs = newDependIDs.ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private List<string> GetPatchAssetAllDependBundles(PatchManifest patchManifest, PatchAsset patchAsset)
|
private List<string> GetPackageAssetAllDependBundles(PackageManifest manifest, PackageAsset packageAsset)
|
||||||
{
|
{
|
||||||
List<string> result = new List<string>();
|
List<string> result = new List<string>();
|
||||||
string mainBundle = patchManifest.BundleList[patchAsset.BundleID].BundleName;
|
string mainBundle = manifest.BundleList[packageAsset.BundleID].BundleName;
|
||||||
result.Add(mainBundle);
|
result.Add(mainBundle);
|
||||||
foreach (var dependID in patchAsset.DependIDs)
|
foreach (var dependID in packageAsset.DependIDs)
|
||||||
{
|
{
|
||||||
string dependBundle = patchManifest.BundleList[dependID].BundleName;
|
string dependBundle = manifest.BundleList[dependID].BundleName;
|
||||||
result.Add(dependBundle);
|
result.Add(dependBundle);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -235,18 +235,18 @@ namespace YooAsset.Editor
|
||||||
private readonly Dictionary<string, int> _cachedBundleID = new Dictionary<string, int>(10000);
|
private readonly Dictionary<string, int> _cachedBundleID = new Dictionary<string, int>(10000);
|
||||||
private readonly Dictionary<string, string[]> _cachedBundleDepends = new Dictionary<string, string[]>(10000);
|
private readonly Dictionary<string, string[]> _cachedBundleDepends = new Dictionary<string, string[]>(10000);
|
||||||
|
|
||||||
private void UpdateScriptPipelineReference(PatchManifest patchManifest, TaskBuilding_SBP.BuildResultContext buildResultContext)
|
private void UpdateScriptPipelineReference(PackageManifest manifest, TaskBuilding_SBP.BuildResultContext buildResultContext)
|
||||||
{
|
{
|
||||||
int progressValue;
|
int progressValue;
|
||||||
int totalCount = patchManifest.BundleList.Count;
|
int totalCount = manifest.BundleList.Count;
|
||||||
|
|
||||||
// 缓存资源包ID
|
// 缓存资源包ID
|
||||||
_cachedBundleID.Clear();
|
_cachedBundleID.Clear();
|
||||||
progressValue = 0;
|
progressValue = 0;
|
||||||
foreach (var patchBundle in patchManifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
int bundleID = GetAssetBundleID(patchBundle.BundleName, patchManifest);
|
int bundleID = GetAssetBundleID(packageBundle.BundleName, manifest);
|
||||||
_cachedBundleID.Add(patchBundle.BundleName, bundleID);
|
_cachedBundleID.Add(packageBundle.BundleName, bundleID);
|
||||||
EditorTools.DisplayProgressBar("缓存资源包索引", ++progressValue, totalCount);
|
EditorTools.DisplayProgressBar("缓存资源包索引", ++progressValue, totalCount);
|
||||||
}
|
}
|
||||||
EditorTools.ClearProgressBar();
|
EditorTools.ClearProgressBar();
|
||||||
|
@ -254,43 +254,43 @@ namespace YooAsset.Editor
|
||||||
// 缓存资源包依赖
|
// 缓存资源包依赖
|
||||||
_cachedBundleDepends.Clear();
|
_cachedBundleDepends.Clear();
|
||||||
progressValue = 0;
|
progressValue = 0;
|
||||||
foreach (var patchBundle in patchManifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
if (patchBundle.IsRawFile)
|
if (packageBundle.IsRawFile)
|
||||||
{
|
{
|
||||||
_cachedBundleDepends.Add(patchBundle.BundleName, new string[] { });
|
_cachedBundleDepends.Add(packageBundle.BundleName, new string[] { });
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buildResultContext.Results.BundleInfos.ContainsKey(patchBundle.BundleName) == false)
|
if (buildResultContext.Results.BundleInfos.ContainsKey(packageBundle.BundleName) == false)
|
||||||
throw new Exception($"Not found bundle in SBP build results : {patchBundle.BundleName}");
|
throw new Exception($"Not found bundle in SBP build results : {packageBundle.BundleName}");
|
||||||
|
|
||||||
var depends = buildResultContext.Results.BundleInfos[patchBundle.BundleName].Dependencies;
|
var depends = buildResultContext.Results.BundleInfos[packageBundle.BundleName].Dependencies;
|
||||||
_cachedBundleDepends.Add(patchBundle.BundleName, depends);
|
_cachedBundleDepends.Add(packageBundle.BundleName, depends);
|
||||||
EditorTools.DisplayProgressBar("缓存资源包依赖列表", ++progressValue, totalCount);
|
EditorTools.DisplayProgressBar("缓存资源包依赖列表", ++progressValue, totalCount);
|
||||||
}
|
}
|
||||||
EditorTools.ClearProgressBar();
|
EditorTools.ClearProgressBar();
|
||||||
|
|
||||||
// 计算资源包引用列表
|
// 计算资源包引用列表
|
||||||
foreach (var patchBundle in patchManifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
patchBundle.ReferenceIDs = GetBundleRefrenceIDs(patchManifest, patchBundle);
|
packageBundle.ReferenceIDs = GetBundleRefrenceIDs(manifest, packageBundle);
|
||||||
EditorTools.DisplayProgressBar("计算资源包引用关系", ++progressValue, totalCount);
|
EditorTools.DisplayProgressBar("计算资源包引用关系", ++progressValue, totalCount);
|
||||||
}
|
}
|
||||||
EditorTools.ClearProgressBar();
|
EditorTools.ClearProgressBar();
|
||||||
}
|
}
|
||||||
private void UpdateBuiltinPipelineReference(PatchManifest patchManifest, TaskBuilding.BuildResultContext buildResultContext)
|
private void UpdateBuiltinPipelineReference(PackageManifest manifest, TaskBuilding.BuildResultContext buildResultContext)
|
||||||
{
|
{
|
||||||
int progressValue;
|
int progressValue;
|
||||||
int totalCount = patchManifest.BundleList.Count;
|
int totalCount = manifest.BundleList.Count;
|
||||||
|
|
||||||
// 缓存资源包ID
|
// 缓存资源包ID
|
||||||
_cachedBundleID.Clear();
|
_cachedBundleID.Clear();
|
||||||
progressValue = 0;
|
progressValue = 0;
|
||||||
foreach (var patchBundle in patchManifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
int bundleID = GetAssetBundleID(patchBundle.BundleName, patchManifest);
|
int bundleID = GetAssetBundleID(packageBundle.BundleName, manifest);
|
||||||
_cachedBundleID.Add(patchBundle.BundleName, bundleID);
|
_cachedBundleID.Add(packageBundle.BundleName, bundleID);
|
||||||
EditorTools.DisplayProgressBar("缓存资源包索引", ++progressValue, totalCount);
|
EditorTools.DisplayProgressBar("缓存资源包索引", ++progressValue, totalCount);
|
||||||
}
|
}
|
||||||
EditorTools.ClearProgressBar();
|
EditorTools.ClearProgressBar();
|
||||||
|
@ -298,36 +298,36 @@ namespace YooAsset.Editor
|
||||||
// 缓存资源包依赖
|
// 缓存资源包依赖
|
||||||
_cachedBundleDepends.Clear();
|
_cachedBundleDepends.Clear();
|
||||||
progressValue = 0;
|
progressValue = 0;
|
||||||
foreach (var patchBundle in patchManifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
if (patchBundle.IsRawFile)
|
if (packageBundle.IsRawFile)
|
||||||
{
|
{
|
||||||
_cachedBundleDepends.Add(patchBundle.BundleName, new string[] { } );
|
_cachedBundleDepends.Add(packageBundle.BundleName, new string[] { } );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var depends = buildResultContext.UnityManifest.GetDirectDependencies(patchBundle.BundleName);
|
var depends = buildResultContext.UnityManifest.GetDirectDependencies(packageBundle.BundleName);
|
||||||
_cachedBundleDepends.Add(patchBundle.BundleName, depends);
|
_cachedBundleDepends.Add(packageBundle.BundleName, depends);
|
||||||
EditorTools.DisplayProgressBar("缓存资源包依赖列表", ++progressValue, totalCount);
|
EditorTools.DisplayProgressBar("缓存资源包依赖列表", ++progressValue, totalCount);
|
||||||
}
|
}
|
||||||
EditorTools.ClearProgressBar();
|
EditorTools.ClearProgressBar();
|
||||||
|
|
||||||
// 计算资源包引用列表
|
// 计算资源包引用列表
|
||||||
progressValue = 0;
|
progressValue = 0;
|
||||||
foreach (var patchBundle in patchManifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
patchBundle.ReferenceIDs = GetBundleRefrenceIDs(patchManifest, patchBundle);
|
packageBundle.ReferenceIDs = GetBundleRefrenceIDs(manifest, packageBundle);
|
||||||
EditorTools.DisplayProgressBar("计算资源包引用关系", ++progressValue, totalCount);
|
EditorTools.DisplayProgressBar("计算资源包引用关系", ++progressValue, totalCount);
|
||||||
}
|
}
|
||||||
EditorTools.ClearProgressBar();
|
EditorTools.ClearProgressBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int[] GetBundleRefrenceIDs(PatchManifest patchManifest, PatchBundle targetBundle)
|
private int[] GetBundleRefrenceIDs(PackageManifest manifest, PackageBundle targetBundle)
|
||||||
{
|
{
|
||||||
List<string> referenceList = new List<string>();
|
List<string> referenceList = new List<string>();
|
||||||
foreach (var patchBundle in patchManifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
string bundleName = patchBundle.BundleName;
|
string bundleName = packageBundle.BundleName;
|
||||||
if (bundleName == targetBundle.BundleName)
|
if (bundleName == targetBundle.BundleName)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -3,8 +3,8 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute("制作补丁包")]
|
[TaskAttribute("制作包裹")]
|
||||||
public class TaskCreatePatchPackage : IBuildTask
|
public class TaskCreatePackage : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
|
@ -13,14 +13,14 @@ namespace YooAsset.Editor
|
||||||
var buildMode = buildParameters.Parameters.BuildMode;
|
var buildMode = buildParameters.Parameters.BuildMode;
|
||||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||||
{
|
{
|
||||||
CopyPatchFiles(buildParameters, buildMapContext);
|
CopyPackageFiles(buildParameters, buildMapContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 拷贝补丁文件到补丁包目录
|
/// 拷贝补丁文件到补丁包目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void CopyPatchFiles(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
private void CopyPackageFiles(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||||
{
|
{
|
||||||
var buildParameters = buildParametersContext.Parameters;
|
var buildParameters = buildParametersContext.Parameters;
|
||||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||||
|
@ -67,11 +67,11 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
// 拷贝所有补丁文件
|
// 拷贝所有补丁文件
|
||||||
int progressValue = 0;
|
int progressValue = 0;
|
||||||
int patchFileTotalCount = buildMapContext.Collection.Count;
|
int fileTotalCount = buildMapContext.Collection.Count;
|
||||||
foreach (var bundleInfo in buildMapContext.Collection)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
{
|
{
|
||||||
EditorTools.CopyFile(bundleInfo.PatchInfo.BuildOutputFilePath, bundleInfo.PatchInfo.PatchOutputFilePath, true);
|
EditorTools.CopyFile(bundleInfo.BundleInfo.BuildOutputFilePath, bundleInfo.BundleInfo.PackageOutputFilePath, true);
|
||||||
EditorTools.DisplayProgressBar("拷贝补丁文件", ++progressValue, patchFileTotalCount);
|
EditorTools.DisplayProgressBar("拷贝补丁文件", ++progressValue, fileTotalCount);
|
||||||
}
|
}
|
||||||
EditorTools.ClearProgressBar();
|
EditorTools.ClearProgressBar();
|
||||||
}
|
}
|
|
@ -12,21 +12,21 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
var patchManifestContext = context.GetContextObject<PatchManifestContext>();
|
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||||
|
|
||||||
var buildMode = buildParameters.Parameters.BuildMode;
|
var buildMode = buildParameters.Parameters.BuildMode;
|
||||||
if (buildMode != EBuildMode.SimulateBuild)
|
if (buildMode != EBuildMode.SimulateBuild)
|
||||||
{
|
{
|
||||||
CreateReportFile(buildParameters, buildMapContext, patchManifestContext);
|
CreateReportFile(buildParameters, buildMapContext, manifestContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateReportFile(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext, PatchManifestContext patchManifestContext)
|
private void CreateReportFile(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext, ManifestContext manifestContext)
|
||||||
{
|
{
|
||||||
var buildParameters = buildParametersContext.Parameters;
|
var buildParameters = buildParametersContext.Parameters;
|
||||||
|
|
||||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||||
PatchManifest patchManifest = patchManifestContext.Manifest;
|
PackageManifest manifest = manifestContext.Manifest;
|
||||||
BuildReport buildReport = new BuildReport();
|
BuildReport buildReport = new BuildReport();
|
||||||
|
|
||||||
// 概述信息
|
// 概述信息
|
||||||
|
@ -57,46 +57,46 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
// 构建结果
|
// 构建结果
|
||||||
buildReport.Summary.AssetFileTotalCount = buildMapContext.AssetFileCount;
|
buildReport.Summary.AssetFileTotalCount = buildMapContext.AssetFileCount;
|
||||||
buildReport.Summary.MainAssetTotalCount = GetMainAssetCount(patchManifest);
|
buildReport.Summary.MainAssetTotalCount = GetMainAssetCount(manifest);
|
||||||
buildReport.Summary.AllBundleTotalCount = GetAllBundleCount(patchManifest);
|
buildReport.Summary.AllBundleTotalCount = GetAllBundleCount(manifest);
|
||||||
buildReport.Summary.AllBundleTotalSize = GetAllBundleSize(patchManifest);
|
buildReport.Summary.AllBundleTotalSize = GetAllBundleSize(manifest);
|
||||||
buildReport.Summary.EncryptedBundleTotalCount = GetEncryptedBundleCount(patchManifest);
|
buildReport.Summary.EncryptedBundleTotalCount = GetEncryptedBundleCount(manifest);
|
||||||
buildReport.Summary.EncryptedBundleTotalSize = GetEncryptedBundleSize(patchManifest);
|
buildReport.Summary.EncryptedBundleTotalSize = GetEncryptedBundleSize(manifest);
|
||||||
buildReport.Summary.RawBundleTotalCount = GetRawBundleCount(patchManifest);
|
buildReport.Summary.RawBundleTotalCount = GetRawBundleCount(manifest);
|
||||||
buildReport.Summary.RawBundleTotalSize = GetRawBundleSize(patchManifest);
|
buildReport.Summary.RawBundleTotalSize = GetRawBundleSize(manifest);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 资源对象列表
|
// 资源对象列表
|
||||||
buildReport.AssetInfos = new List<ReportAssetInfo>(patchManifest.AssetList.Count);
|
buildReport.AssetInfos = new List<ReportAssetInfo>(manifest.AssetList.Count);
|
||||||
foreach (var patchAsset in patchManifest.AssetList)
|
foreach (var packageAsset in manifest.AssetList)
|
||||||
{
|
{
|
||||||
var mainBundle = patchManifest.BundleList[patchAsset.BundleID];
|
var mainBundle = manifest.BundleList[packageAsset.BundleID];
|
||||||
ReportAssetInfo reportAssetInfo = new ReportAssetInfo();
|
ReportAssetInfo reportAssetInfo = new ReportAssetInfo();
|
||||||
reportAssetInfo.Address = patchAsset.Address;
|
reportAssetInfo.Address = packageAsset.Address;
|
||||||
reportAssetInfo.AssetPath = patchAsset.AssetPath;
|
reportAssetInfo.AssetPath = packageAsset.AssetPath;
|
||||||
reportAssetInfo.AssetTags = patchAsset.AssetTags;
|
reportAssetInfo.AssetTags = packageAsset.AssetTags;
|
||||||
reportAssetInfo.AssetGUID = AssetDatabase.AssetPathToGUID(patchAsset.AssetPath);
|
reportAssetInfo.AssetGUID = AssetDatabase.AssetPathToGUID(packageAsset.AssetPath);
|
||||||
reportAssetInfo.MainBundleName = mainBundle.BundleName;
|
reportAssetInfo.MainBundleName = mainBundle.BundleName;
|
||||||
reportAssetInfo.MainBundleSize = mainBundle.FileSize;
|
reportAssetInfo.MainBundleSize = mainBundle.FileSize;
|
||||||
reportAssetInfo.DependBundles = GetDependBundles(patchManifest, patchAsset);
|
reportAssetInfo.DependBundles = GetDependBundles(manifest, packageAsset);
|
||||||
reportAssetInfo.DependAssets = GetDependAssets(buildMapContext, mainBundle.BundleName, patchAsset.AssetPath);
|
reportAssetInfo.DependAssets = GetDependAssets(buildMapContext, mainBundle.BundleName, packageAsset.AssetPath);
|
||||||
buildReport.AssetInfos.Add(reportAssetInfo);
|
buildReport.AssetInfos.Add(reportAssetInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 资源包列表
|
// 资源包列表
|
||||||
buildReport.BundleInfos = new List<ReportBundleInfo>(patchManifest.BundleList.Count);
|
buildReport.BundleInfos = new List<ReportBundleInfo>(manifest.BundleList.Count);
|
||||||
foreach (var patchBundle in patchManifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
ReportBundleInfo reportBundleInfo = new ReportBundleInfo();
|
ReportBundleInfo reportBundleInfo = new ReportBundleInfo();
|
||||||
reportBundleInfo.BundleName = patchBundle.BundleName;
|
reportBundleInfo.BundleName = packageBundle.BundleName;
|
||||||
reportBundleInfo.FileName = patchBundle.FileName;
|
reportBundleInfo.FileName = packageBundle.FileName;
|
||||||
reportBundleInfo.FileHash = patchBundle.FileHash;
|
reportBundleInfo.FileHash = packageBundle.FileHash;
|
||||||
reportBundleInfo.FileCRC = patchBundle.FileCRC;
|
reportBundleInfo.FileCRC = packageBundle.FileCRC;
|
||||||
reportBundleInfo.FileSize = patchBundle.FileSize;
|
reportBundleInfo.FileSize = packageBundle.FileSize;
|
||||||
reportBundleInfo.Tags = patchBundle.Tags;
|
reportBundleInfo.Tags = packageBundle.Tags;
|
||||||
reportBundleInfo.ReferenceIDs = patchBundle.ReferenceIDs;
|
reportBundleInfo.ReferenceIDs = packageBundle.ReferenceIDs;
|
||||||
reportBundleInfo.IsRawFile = patchBundle.IsRawFile;
|
reportBundleInfo.IsRawFile = packageBundle.IsRawFile;
|
||||||
reportBundleInfo.LoadMethod = (EBundleLoadMethod)patchBundle.LoadMethod;
|
reportBundleInfo.LoadMethod = (EBundleLoadMethod)packageBundle.LoadMethod;
|
||||||
buildReport.BundleInfos.Add(reportBundleInfo);
|
buildReport.BundleInfos.Add(reportBundleInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,12 +110,12 @@ namespace YooAsset.Editor
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源对象依赖的所有资源包
|
/// 获取资源对象依赖的所有资源包
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private List<string> GetDependBundles(PatchManifest patchManifest, PatchAsset patchAsset)
|
private List<string> GetDependBundles(PackageManifest manifest, PackageAsset packageAsset)
|
||||||
{
|
{
|
||||||
List<string> dependBundles = new List<string>(patchAsset.DependIDs.Length);
|
List<string> dependBundles = new List<string>(packageAsset.DependIDs.Length);
|
||||||
foreach (int index in patchAsset.DependIDs)
|
foreach (int index in packageAsset.DependIDs)
|
||||||
{
|
{
|
||||||
string dependBundleName = patchManifest.BundleList[index].BundleName;
|
string dependBundleName = manifest.BundleList[index].BundleName;
|
||||||
dependBundles.Add(dependBundleName);
|
dependBundles.Add(dependBundleName);
|
||||||
}
|
}
|
||||||
return dependBundles;
|
return dependBundles;
|
||||||
|
@ -150,60 +150,60 @@ namespace YooAsset.Editor
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GetMainAssetCount(PatchManifest patchManifest)
|
private int GetMainAssetCount(PackageManifest manifest)
|
||||||
{
|
{
|
||||||
return patchManifest.AssetList.Count;
|
return manifest.AssetList.Count;
|
||||||
}
|
}
|
||||||
private int GetAllBundleCount(PatchManifest patchManifest)
|
private int GetAllBundleCount(PackageManifest manifest)
|
||||||
{
|
{
|
||||||
return patchManifest.BundleList.Count;
|
return manifest.BundleList.Count;
|
||||||
}
|
}
|
||||||
private long GetAllBundleSize(PatchManifest patchManifest)
|
private long GetAllBundleSize(PackageManifest manifest)
|
||||||
{
|
{
|
||||||
long fileBytes = 0;
|
long fileBytes = 0;
|
||||||
foreach (var patchBundle in patchManifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
fileBytes += patchBundle.FileSize;
|
fileBytes += packageBundle.FileSize;
|
||||||
}
|
}
|
||||||
return fileBytes;
|
return fileBytes;
|
||||||
}
|
}
|
||||||
private int GetEncryptedBundleCount(PatchManifest patchManifest)
|
private int GetEncryptedBundleCount(PackageManifest manifest)
|
||||||
{
|
{
|
||||||
int fileCount = 0;
|
int fileCount = 0;
|
||||||
foreach (var patchBundle in patchManifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
if (patchBundle.LoadMethod != (byte)EBundleLoadMethod.Normal)
|
if (packageBundle.LoadMethod != (byte)EBundleLoadMethod.Normal)
|
||||||
fileCount++;
|
fileCount++;
|
||||||
}
|
}
|
||||||
return fileCount;
|
return fileCount;
|
||||||
}
|
}
|
||||||
private long GetEncryptedBundleSize(PatchManifest patchManifest)
|
private long GetEncryptedBundleSize(PackageManifest manifest)
|
||||||
{
|
{
|
||||||
long fileBytes = 0;
|
long fileBytes = 0;
|
||||||
foreach (var patchBundle in patchManifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
if (patchBundle.LoadMethod != (byte)EBundleLoadMethod.Normal)
|
if (packageBundle.LoadMethod != (byte)EBundleLoadMethod.Normal)
|
||||||
fileBytes += patchBundle.FileSize;
|
fileBytes += packageBundle.FileSize;
|
||||||
}
|
}
|
||||||
return fileBytes;
|
return fileBytes;
|
||||||
}
|
}
|
||||||
private int GetRawBundleCount(PatchManifest patchManifest)
|
private int GetRawBundleCount(PackageManifest manifest)
|
||||||
{
|
{
|
||||||
int fileCount = 0;
|
int fileCount = 0;
|
||||||
foreach (var patchBundle in patchManifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
if (patchBundle.IsRawFile)
|
if (packageBundle.IsRawFile)
|
||||||
fileCount++;
|
fileCount++;
|
||||||
}
|
}
|
||||||
return fileCount;
|
return fileCount;
|
||||||
}
|
}
|
||||||
private long GetRawBundleSize(PatchManifest patchManifest)
|
private long GetRawBundleSize(PackageManifest manifest)
|
||||||
{
|
{
|
||||||
long fileBytes = 0;
|
long fileBytes = 0;
|
||||||
foreach (var patchBundle in patchManifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
if (patchBundle.IsRawFile)
|
if (packageBundle.IsRawFile)
|
||||||
fileBytes += patchBundle.FileSize;
|
fileBytes += packageBundle.FileSize;
|
||||||
}
|
}
|
||||||
return fileBytes;
|
return fileBytes;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,8 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute("更新补丁信息")]
|
[TaskAttribute("更新资源包信息")]
|
||||||
public class TaskUpdatePatchInfo : IBuildTask
|
public class TaskUpdateBundleInfo : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
|
@ -30,27 +30,27 @@ namespace YooAsset.Editor
|
||||||
foreach (var bundleInfo in buildMapContext.Collection)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
{
|
{
|
||||||
if (bundleInfo.IsEncryptedFile)
|
if (bundleInfo.IsEncryptedFile)
|
||||||
bundleInfo.PatchInfo.BuildOutputFilePath = bundleInfo.EncryptedFilePath;
|
bundleInfo.BundleInfo.BuildOutputFilePath = bundleInfo.EncryptedFilePath;
|
||||||
else
|
else
|
||||||
bundleInfo.PatchInfo.BuildOutputFilePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
bundleInfo.BundleInfo.BuildOutputFilePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3.更新文件其它信息
|
// 3.更新文件其它信息
|
||||||
foreach (var bundleInfo in buildMapContext.Collection)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
{
|
{
|
||||||
string buildOutputFilePath = bundleInfo.PatchInfo.BuildOutputFilePath;
|
string buildOutputFilePath = bundleInfo.BundleInfo.BuildOutputFilePath;
|
||||||
bundleInfo.PatchInfo.ContentHash = GetBundleContentHash(bundleInfo, context);
|
bundleInfo.BundleInfo.ContentHash = GetBundleContentHash(bundleInfo, context);
|
||||||
bundleInfo.PatchInfo.PatchFileHash = GetBundleFileHash(buildOutputFilePath, buildParametersContext);
|
bundleInfo.BundleInfo.FileHash = GetBundleFileHash(buildOutputFilePath, buildParametersContext);
|
||||||
bundleInfo.PatchInfo.PatchFileCRC = GetBundleFileCRC(buildOutputFilePath, buildParametersContext);
|
bundleInfo.BundleInfo.FileCRC = GetBundleFileCRC(buildOutputFilePath, buildParametersContext);
|
||||||
bundleInfo.PatchInfo.PatchFileSize = GetBundleFileSize(buildOutputFilePath, buildParametersContext);
|
bundleInfo.BundleInfo.FileSize = GetBundleFileSize(buildOutputFilePath, buildParametersContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4.更新补丁包输出的文件路径
|
// 4.更新补丁包输出的文件路径
|
||||||
foreach (var bundleInfo in buildMapContext.Collection)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
{
|
{
|
||||||
string patchFileExtension = PatchManifestTools.GetRemoteBundleFileExtension(bundleInfo.BundleName);
|
string fileExtension = ManifestTools.GetRemoteBundleFileExtension(bundleInfo.BundleName);
|
||||||
string patchFileName = PatchManifestTools.GetRemoteBundleFileName(outputNameStyle, bundleInfo.BundleName, patchFileExtension, bundleInfo.PatchInfo.PatchFileHash);
|
string fileName = ManifestTools.GetRemoteBundleFileName(outputNameStyle, bundleInfo.BundleName, fileExtension, bundleInfo.BundleInfo.FileHash);
|
||||||
bundleInfo.PatchInfo.PatchOutputFilePath = $"{packageOutputDirectory}/{patchFileName}";
|
bundleInfo.BundleInfo.PackageOutputFilePath = $"{packageOutputDirectory}/{fileName}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
if (bundleInfo.IsRawFile)
|
if (bundleInfo.IsRawFile)
|
||||||
{
|
{
|
||||||
string filePath = bundleInfo.PatchInfo.BuildOutputFilePath;
|
string filePath = bundleInfo.BundleInfo.BuildOutputFilePath;
|
||||||
return HashUtility.FileMD5(filePath);
|
return HashUtility.FileMD5(filePath);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue