diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs
index 0b4618d..5680f3a 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs
@@ -181,6 +181,7 @@ namespace YooAsset.Editor
new TaskEncryption(), //加密资源文件
new TaskCreatePatchManifest(), //创建清单文件
new TaskCreateReadme(), //创建说明文件
+ new TaskCreateReport(), //创建报告文件
new TaskCreatePatchPackage(), //制作补丁包
new TaskCopyBuildinFiles(), //拷贝内置文件
};
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/BuildReport.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/BuildReport.cs
index 309621a..73cc041 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/BuildReport.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/BuildReport.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
+using UnityEngine;
namespace YooAsset.Editor
{
@@ -10,40 +11,29 @@ namespace YooAsset.Editor
[Serializable]
public class BuildReport
{
+ ///
+ /// 构建汇总信息
+ ///
+ public BuildSummary Summary = new BuildSummary();
+
///
/// 资源包列表
///
- public readonly List BundleInfos = new List(1000);
+ public List BundleInfos;
///
/// 冗余的资源列表
///
- public readonly List RedundancyList = new List(1000);
+ public List RedundancyList;
///
- /// 检测是否包含BundleName
+ /// 序列化
///
- public bool IsContainsBundle(string bundleFullName)
+ public static void Serialize(string savePath, BuildReport buildReport)
{
- return TryGetBundleInfo(bundleFullName, out BuildBundleInfo bundleInfo);
- }
-
- ///
- /// 尝试获取资源包类,如果没有返回空
- ///
- public bool TryGetBundleInfo(string bundleFullName, out BuildBundleInfo result)
- {
- foreach (var bundleInfo in BundleInfos)
- {
- if (bundleInfo.BundleName == bundleFullName)
- {
- result = bundleInfo;
- return true;
- }
- }
- result = null;
- return false;
+ string json = JsonUtility.ToJson(buildReport, true);
+ FileUtility.CreateFile(savePath, json);
}
}
}
\ No newline at end of file
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/BuildSummary.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/BuildSummary.cs
new file mode 100644
index 0000000..1eed88c
--- /dev/null
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/BuildSummary.cs
@@ -0,0 +1,59 @@
+using System;
+using UnityEditor;
+
+namespace YooAsset.Editor
+{
+ [Serializable]
+ public class BuildSummary
+ {
+ ///
+ /// 引擎版本
+ ///
+ public string UnityVersion;
+
+ ///
+ /// 构建时间
+ ///
+ public string BuildTime;
+
+ ///
+ /// 构建耗时(单位:秒)
+ ///
+ public int BuildSeconds;
+
+ ///
+ /// 构建平台
+ ///
+ public BuildTarget BuildTarget;
+
+ ///
+ /// 构建版本
+ ///
+ public int BuildVersion;
+
+ ///
+ /// 是否开启冗余机制
+ ///
+ public bool ApplyRedundancy;
+
+ ///
+ /// 是否开启文件后缀名
+ ///
+ public bool AppendFileExtension;
+
+ #region 着色器
+ public bool IsCollectAllShaders;
+ public string ShadersBundleName;
+ #endregion
+
+ #region 构建参数
+ public bool IsForceRebuild;
+ public string BuildinTags;
+ public ECompressOption CompressOption;
+ public bool IsAppendHash;
+ public bool IsDisableWriteTypeTree;
+ public bool IsIgnoreTypeTreeChanges;
+ public bool IsDisableLoadAssetByFileName;
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/BuildSummary.cs.meta b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/BuildSummary.cs.meta
new file mode 100644
index 0000000..b6be17d
--- /dev/null
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/BuildSummary.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: cc215f5628022c345be919a0e21fcc8c
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskBuilding.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskBuilding.cs
index f8ba7e4..78c945a 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskBuilding.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskBuilding.cs
@@ -31,7 +31,7 @@ namespace YooAsset.Editor
context.SetContextObject(unityManifestContext);
// 拷贝原生文件
- foreach (var bundleInfo in buildMapContext.Report.BundleInfos)
+ foreach (var bundleInfo in buildMapContext.BundleInfos)
{
if (bundleInfo.IsRawFile)
{
@@ -62,7 +62,7 @@ namespace YooAsset.Editor
// 1. 过滤掉原生Bundle
List expectBundles = new List(buildedBundles.Length);
- foreach(var bundleInfo in buildMapContext.Report.BundleInfos)
+ foreach(var bundleInfo in buildMapContext.BundleInfos)
{
if (bundleInfo.IsRawFile == false)
expectBundles.Add(bundleInfo);
@@ -77,7 +77,7 @@ namespace YooAsset.Editor
// 3. 正向验证Bundle
foreach (var bundleName in buildedBundles)
{
- if (buildMapContext.Report.IsContainsBundle(bundleName) == false)
+ if (buildMapContext.IsContainsBundle(bundleName) == false)
{
throw new Exception($"Should never get here !");
}
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs
index 46c0bb5..491f6f3 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs
@@ -61,7 +61,7 @@ namespace YooAsset.Editor
oldPatchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(buildParameters.PipelineOutputDirectory);
}
- foreach (var bundleInfo in buildMapContext.Report.BundleInfos)
+ foreach (var bundleInfo in buildMapContext.BundleInfos)
{
var bundleName = bundleInfo.BundleName;
string filePath = $"{buildParameters.PipelineOutputDirectory}/{bundleName}";
@@ -114,7 +114,7 @@ namespace YooAsset.Editor
private List GetAllPatchAsset(TaskGetBuildMap.BuildMapContext buildMapContext, PatchManifest patchManifest)
{
List result = new List(1000);
- foreach (var bundleInfo in buildMapContext.Report.BundleInfos)
+ foreach (var bundleInfo in buildMapContext.BundleInfos)
{
var assetInfos = bundleInfo.GetCollectAssetInfos();
foreach (var assetInfo in assetInfos)
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReadme.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReadme.cs
index cbdbc9c..14e4108 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReadme.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReadme.cs
@@ -77,17 +77,17 @@ namespace YooAsset.Editor
AppendData(content, "");
AppendData(content, $"--冗余列表--");
- for (int i = 0; i < buildMapContext.Report.RedundancyList.Count; i++)
+ for (int i = 0; i < buildMapContext.RedundancyList.Count; i++)
{
- string redundancyAssetPath = buildMapContext.Report.RedundancyList[i];
+ string redundancyAssetPath = buildMapContext.RedundancyList[i];
AppendData(content, redundancyAssetPath);
}
AppendData(content, "");
AppendData(content, $"--构建列表--");
- for (int i = 0; i < buildMapContext.Report.BundleInfos.Count; i++)
+ for (int i = 0; i < buildMapContext.BundleInfos.Count; i++)
{
- string bundleName = buildMapContext.Report.BundleInfos[i].BundleName;
+ string bundleName = buildMapContext.BundleInfos[i].BundleName;
AppendData(content, bundleName);
}
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs
new file mode 100644
index 0000000..fb72fe7
--- /dev/null
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs
@@ -0,0 +1,54 @@
+using System;
+using System.IO;
+using System.Text;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace YooAsset.Editor
+{
+ ///
+ /// 创建报告文件
+ ///
+ public class TaskCreateReport : IBuildTask
+ {
+ void IBuildTask.Run(BuildContext context)
+ {
+ var buildParameters = context.GetContextObject();
+ var buildMapContext = context.GetContextObject();
+ CreateReportFile(buildParameters, buildMapContext);
+ }
+
+ private void CreateReportFile(AssetBundleBuilder.BuildParametersContext buildParameters, TaskGetBuildMap.BuildMapContext buildMapContext)
+ {
+ BuildReport buildReport = new BuildReport();
+
+ buildReport.Summary.UnityVersion = UnityEngine.Application.unityVersion;
+ buildReport.Summary.BuildTime = DateTime.Now.ToString();
+ buildReport.Summary.BuildSeconds = 0;
+ buildReport.Summary.BuildTarget = buildParameters.Parameters.BuildTarget;
+ buildReport.Summary.BuildVersion = buildParameters.Parameters.BuildVersion;
+ buildReport.Summary.ApplyRedundancy = buildParameters.Parameters.ApplyRedundancy;
+ buildReport.Summary.AppendFileExtension = buildParameters.Parameters.AppendFileExtension;
+
+ buildReport.Summary.IsCollectAllShaders = AssetBundleCollectorSettingData.Setting.IsCollectAllShaders;
+ buildReport.Summary.ShadersBundleName = AssetBundleCollectorSettingData.Setting.ShadersBundleName;
+
+ buildReport.Summary.IsForceRebuild = buildParameters.Parameters.IsForceRebuild;
+ buildReport.Summary.BuildinTags = buildParameters.Parameters.BuildinTags;
+ buildReport.Summary.CompressOption = buildParameters.Parameters.CompressOption;
+ buildReport.Summary.IsAppendHash = buildParameters.Parameters.IsAppendHash;
+ buildReport.Summary.IsDisableWriteTypeTree = buildParameters.Parameters.IsDisableWriteTypeTree;
+ buildReport.Summary.IsIgnoreTypeTreeChanges = buildParameters.Parameters.IsIgnoreTypeTreeChanges;
+ buildReport.Summary.IsDisableLoadAssetByFileName = buildParameters.Parameters.IsDisableLoadAssetByFileName;
+
+ buildReport.BundleInfos = buildMapContext.BundleInfos;
+ buildReport.RedundancyList = buildMapContext.RedundancyList;
+
+ // 删除旧文件
+ string filePath = $"{buildParameters.PipelineOutputDirectory}/{ResourceSettingData.Setting.ReportFileName}";
+ if (File.Exists(filePath))
+ File.Delete(filePath);
+ BuildReport.Serialize(filePath, buildReport);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs.meta b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs.meta
new file mode 100644
index 0000000..b37114b
--- /dev/null
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: bd12814185b4c7044b0afd59f9c1c948
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskEncryption.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskEncryption.cs
index 5e92ed9..d40dc1e 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskEncryption.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskEncryption.cs
@@ -64,7 +64,7 @@ namespace YooAsset.Editor
UnityEngine.Debug.Log($"开始加密资源文件");
int progressValue = 0;
- foreach (var bundleInfo in buildMapContext.Report.BundleInfos)
+ foreach (var bundleInfo in buildMapContext.BundleInfos)
{
var bundleName = bundleInfo.BundleName;
string filePath = $"{buildParameters.PipelineOutputDirectory}/{bundleName}";
@@ -83,7 +83,7 @@ namespace YooAsset.Editor
}
// 进度条
- EditorTools.DisplayProgressBar("加密资源包", ++progressValue, buildMapContext.Report.BundleInfos.Count);
+ EditorTools.DisplayProgressBar("加密资源包", ++progressValue, buildMapContext.BundleInfos.Count);
}
EditorTools.ClearProgressBar();
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs
index ca8cba6..56d21f5 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs
@@ -11,14 +11,23 @@ namespace YooAsset.Editor
{
public class BuildMapContext : IContextObject
{
- public BuildReport Report = new BuildReport();
+ ///
+ /// 资源包列表
+ ///
+ public readonly List BundleInfos = new List(1000);
+
+ ///
+ /// 冗余的资源列表
+ ///
+ public readonly List RedundancyList = new List(1000);
+
///
/// 添加一个打包资源
///
public void PackAsset(BuildAssetInfo assetInfo)
{
- if (Report.TryGetBundleInfo(assetInfo.BundleName, out BuildBundleInfo bundleInfo))
+ if (TryGetBundleInfo(assetInfo.BundleName, out BuildBundleInfo bundleInfo))
{
bundleInfo.PackAsset(assetInfo);
}
@@ -26,7 +35,7 @@ namespace YooAsset.Editor
{
BuildBundleInfo newBundleInfo = new BuildBundleInfo(assetInfo.BundleName);
newBundleInfo.PackAsset(assetInfo);
- Report.BundleInfos.Add(newBundleInfo);
+ BundleInfos.Add(newBundleInfo);
}
}
@@ -35,8 +44,8 @@ namespace YooAsset.Editor
///
public List GetAllAssets()
{
- List result = new List(Report.BundleInfos.Count);
- foreach (var bundleInfo in Report.BundleInfos)
+ List result = new List(BundleInfos.Count);
+ foreach (var bundleInfo in BundleInfos)
{
result.AddRange(bundleInfo.Assets);
}
@@ -48,7 +57,7 @@ namespace YooAsset.Editor
///
public string[] GetAssetTags(string bundleFullName)
{
- if (Report.TryGetBundleInfo(bundleFullName, out BuildBundleInfo bundleInfo))
+ if (TryGetBundleInfo(bundleFullName, out BuildBundleInfo bundleInfo))
{
return bundleInfo.GetAssetTags();
}
@@ -60,7 +69,7 @@ namespace YooAsset.Editor
///
public string[] GetBuildinAssetPaths(string bundleFullName)
{
- if (Report.TryGetBundleInfo(bundleFullName, out BuildBundleInfo bundleInfo))
+ if (TryGetBundleInfo(bundleFullName, out BuildBundleInfo bundleInfo))
{
return bundleInfo.GetBuildinAssetPaths();
}
@@ -72,14 +81,36 @@ namespace YooAsset.Editor
///
public UnityEditor.AssetBundleBuild[] GetPipelineBuilds()
{
- List builds = new List(Report.BundleInfos.Count);
- foreach (var bundleInfo in Report.BundleInfos)
+ List builds = new List(BundleInfos.Count);
+ foreach (var bundleInfo in BundleInfos)
{
if (bundleInfo.IsRawFile == false)
builds.Add(bundleInfo.CreatePipelineBuild());
}
return builds.ToArray();
}
+
+ ///
+ /// 是否包含资源包
+ ///
+ public bool IsContainsBundle(string bundleFullName)
+ {
+ return TryGetBundleInfo(bundleFullName, out BuildBundleInfo bundleInfo);
+ }
+
+ private bool TryGetBundleInfo(string bundleFullName, out BuildBundleInfo result)
+ {
+ foreach (var bundleInfo in BundleInfos)
+ {
+ if (bundleInfo.BundleName == bundleFullName)
+ {
+ result = bundleInfo;
+ return true;
+ }
+ }
+ result = null;
+ return false;
+ }
}
@@ -169,7 +200,7 @@ namespace YooAsset.Editor
if(redundancy.Check(buildAssetInfo.AssetPath))
{
undependentAssets.Add(buildAssetInfo);
- buildMapContext.Report.RedundancyList.Add(buildAssetInfo.AssetPath);
+ buildMapContext.RedundancyList.Add(buildAssetInfo.AssetPath);
continue;
}
}
@@ -180,7 +211,7 @@ namespace YooAsset.Editor
if (AssetBundleCollectorSettingData.HasCollector(buildAssetInfo.AssetPath) == false)
{
undependentAssets.Add(buildAssetInfo);
- buildMapContext.Report.RedundancyList.Add(buildAssetInfo.AssetPath);
+ buildMapContext.RedundancyList.Add(buildAssetInfo.AssetPath);
}
}
}
@@ -237,7 +268,7 @@ namespace YooAsset.Editor
///
private void CheckBuildMapContent(BuildMapContext buildMapContext)
{
- foreach (var bundleInfo in buildMapContext.Report.BundleInfos)
+ foreach (var bundleInfo in buildMapContext.BundleInfos)
{
// 注意:原生文件资源包只能包含一个原生文件
bool isRawFile = bundleInfo.IsRawFile;