From 7cb0394785eb9d62a9a42c94922e0f0b5440e005 Mon Sep 17 00:00:00 2001 From: hevinci Date: Thu, 17 Mar 2022 15:27:49 +0800 Subject: [PATCH] Update AssetBundleBuilder --- .../{BuildReport => }/BuildAssetInfo.cs | 36 ++++++++++--------- .../{BuildReport => }/BuildAssetInfo.cs.meta | 0 .../{BuildReport => }/BuildBundleInfo.cs | 8 ++--- .../{BuildReport => }/BuildBundleInfo.cs.meta | 0 .../BuildReport/BuildReport.cs | 11 +++++- .../BuildReport/ReportAssetInfo.cs | 12 +++++++ .../BuildReport/ReportAssetInfo.cs.meta | 11 ++++++ .../BuildReport/ReportBundleInfo.cs | 12 +++++++ .../BuildReport/ReportBundleInfo.cs.meta | 11 ++++++ .../BuildTasks/TaskCreateReport.cs | 2 +- 10 files changed, 79 insertions(+), 24 deletions(-) rename Assets/YooAsset/Editor/AssetBundleBuilder/{BuildReport => }/BuildAssetInfo.cs (80%) rename Assets/YooAsset/Editor/AssetBundleBuilder/{BuildReport => }/BuildAssetInfo.cs.meta (100%) rename Assets/YooAsset/Editor/AssetBundleBuilder/{BuildReport => }/BuildBundleInfo.cs (93%) rename Assets/YooAsset/Editor/AssetBundleBuilder/{BuildReport => }/BuildBundleInfo.cs.meta (100%) create mode 100644 Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportAssetInfo.cs create mode 100644 Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportAssetInfo.cs.meta create mode 100644 Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportBundleInfo.cs create mode 100644 Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportBundleInfo.cs.meta diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/BuildAssetInfo.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs similarity index 80% rename from Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/BuildAssetInfo.cs rename to Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs index 601fad4..a84caf7 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/BuildAssetInfo.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs @@ -4,21 +4,17 @@ using System.Collections.Generic; namespace YooAsset.Editor { - /// - /// 构建的资源信息类 - /// - [Serializable] public class BuildAssetInfo { /// /// 资源路径 /// - public string AssetPath; + public string AssetPath { private set; get; } /// /// 资源包完整名称 /// - public string BundleName; + public string BundleName { private set; get; } /// /// 是否为原生资源 @@ -30,21 +26,21 @@ namespace YooAsset.Editor /// public bool IsCollectAsset = false; - /// - /// 资源标记列表 - /// - public List AssetTags = new List(); - /// /// 被依赖次数 /// public int DependCount = 0; + /// + /// 资源标记列表 + /// + public readonly List AssetTags = new List(); + /// /// 依赖的所有资源 /// 注意:包括零依赖资源和冗余资源(资源包名无效) /// - public List AllDependAssetInfos; + public List AllDependAssetInfos { private set; get; } public BuildAssetInfo(string assetPath) @@ -81,10 +77,18 @@ namespace YooAsset.Editor { foreach (var tag in tags) { - if (AssetTags.Contains(tag) == false) - { - AssetTags.Add(tag); - } + AddAssetTag(tag); + } + } + + /// + /// 添加资源标记 + /// + public void AddAssetTag(string tag) + { + if (AssetTags.Contains(tag) == false) + { + AssetTags.Add(tag); } } diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/BuildAssetInfo.cs.meta b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs.meta similarity index 100% rename from Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/BuildAssetInfo.cs.meta rename to Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs.meta diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/BuildBundleInfo.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildBundleInfo.cs similarity index 93% rename from Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/BuildBundleInfo.cs rename to Assets/YooAsset/Editor/AssetBundleBuilder/BuildBundleInfo.cs index 7d39a39..c1cea38 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/BuildBundleInfo.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildBundleInfo.cs @@ -6,21 +6,17 @@ using UnityEditor; namespace YooAsset.Editor { - /// - /// 构建的资源包信息类 - /// - [Serializable] public class BuildBundleInfo { /// /// 资源包完整名称 /// - public string BundleName; + public string BundleName { private set; get; } /// /// 包含的资源列表 /// - public List Assets = new List(); + public readonly List Assets = new List(); /// /// 是否为原生文件 diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/BuildBundleInfo.cs.meta b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildBundleInfo.cs.meta similarity index 100% rename from Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/BuildBundleInfo.cs.meta rename to Assets/YooAsset/Editor/AssetBundleBuilder/BuildBundleInfo.cs.meta diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/BuildReport.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/BuildReport.cs index 73cc041..3d93a5c 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/BuildReport.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/BuildReport.cs @@ -19,7 +19,7 @@ namespace YooAsset.Editor /// /// 资源包列表 /// - public List BundleInfos; + public List BundleInfos; /// /// 冗余的资源列表 @@ -35,5 +35,14 @@ namespace YooAsset.Editor string json = JsonUtility.ToJson(buildReport, true); FileUtility.CreateFile(savePath, json); } + + /// + /// 反序列化 + /// + public static BuildReport Deserialize(string jsonData) + { + BuildReport report = JsonUtility.FromJson(jsonData); + return report; + } } } \ No newline at end of file diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportAssetInfo.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportAssetInfo.cs new file mode 100644 index 0000000..5b21fbf --- /dev/null +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportAssetInfo.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections; +using System.Collections.Generic; + +namespace YooAsset.Editor +{ + [Serializable] + public class ReportAssetInfo + { + + } +} \ No newline at end of file diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportAssetInfo.cs.meta b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportAssetInfo.cs.meta new file mode 100644 index 0000000..de2a0e9 --- /dev/null +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportAssetInfo.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3ef16d696d8ffbd488c27e539f1966ad +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportBundleInfo.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportBundleInfo.cs new file mode 100644 index 0000000..73afc48 --- /dev/null +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportBundleInfo.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections; +using System.Collections.Generic; + +namespace YooAsset.Editor +{ + [Serializable] + public class ReportBundleInfo + { + + } +} \ No newline at end of file diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportBundleInfo.cs.meta b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportBundleInfo.cs.meta new file mode 100644 index 0000000..1a793ba --- /dev/null +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportBundleInfo.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 26aa55851e9252b4ab0655ee60526cb0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs index fb72fe7..791b231 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs @@ -41,7 +41,7 @@ namespace YooAsset.Editor buildReport.Summary.IsIgnoreTypeTreeChanges = buildParameters.Parameters.IsIgnoreTypeTreeChanges; buildReport.Summary.IsDisableLoadAssetByFileName = buildParameters.Parameters.IsDisableLoadAssetByFileName; - buildReport.BundleInfos = buildMapContext.BundleInfos; + //buildReport.BundleInfos = buildMapContext.BundleInfos; buildReport.RedundancyList = buildMapContext.RedundancyList; // 删除旧文件