diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildBundleInfo.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildBundleInfo.cs index b17a96b..ac03157 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildBundleInfo.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildBundleInfo.cs @@ -51,7 +51,7 @@ namespace YooAsset.Editor /// 参与构建的资源列表 /// 注意:不包含零依赖资源 /// - public readonly List BuildinAssets = new List(); + public readonly List AllMainAssets = new List(); /// /// 补丁文件信息 @@ -76,9 +76,9 @@ namespace YooAsset.Editor { get { - foreach (var asset in BuildinAssets) + foreach (var assetInfo in AllMainAssets) { - if (asset.IsRawAsset) + if (assetInfo.IsRawAsset) return true; } return false; @@ -113,7 +113,7 @@ namespace YooAsset.Editor if (IsContainsAsset(assetInfo.AssetPath)) throw new System.Exception($"Asset is existed : {assetInfo.AssetPath}"); - BuildinAssets.Add(assetInfo); + AllMainAssets.Add(assetInfo); } /// @@ -121,7 +121,7 @@ namespace YooAsset.Editor /// public bool IsContainsAsset(string assetPath) { - foreach (var assetInfo in BuildinAssets) + foreach (var assetInfo in AllMainAssets) { if (assetInfo.AssetPath == assetPath) { @@ -136,8 +136,8 @@ namespace YooAsset.Editor /// public string[] GetBundleTags() { - List result = new List(BuildinAssets.Count); - foreach (var assetInfo in BuildinAssets) + List result = new List(AllMainAssets.Count); + foreach (var assetInfo in AllMainAssets) { foreach (var assetTag in assetInfo.BundleTags) { @@ -148,20 +148,43 @@ namespace YooAsset.Editor return result.ToArray(); } + /// + /// 获取该资源包内的所有资源(包括零依赖资源) + /// + public List GetAllBuiltinAssetPaths() + { + var packAssets = GetAllMainAssetPaths(); + List result = new List(packAssets); + foreach (var assetInfo in AllMainAssets) + { + if (assetInfo.AllDependAssetInfos == null) + continue; + foreach (var depend in assetInfo.AllDependAssetInfos) + { + if (depend.HasBundleName() == false) + { + if (result.Contains(depend.AssetPath) == false) + result.Add(depend.AssetPath); + } + } + } + return result; + } + /// /// 获取构建的资源路径列表 /// - public string[] GetBuildinAssetPaths() + public string[] GetAllMainAssetPaths() { - return BuildinAssets.Select(t => t.AssetPath).ToArray(); + return AllMainAssets.Select(t => t.AssetPath).ToArray(); } /// /// 获取所有写入补丁清单的资源 /// - public BuildAssetInfo[] GetAllBuildAssetInfos() + public BuildAssetInfo[] GetAllMainAssetInfos() { - return BuildinAssets.Where(t => t.CollectorType == ECollectorType.MainAssetCollector).ToArray(); + return AllMainAssets.Where(t => t.CollectorType == ECollectorType.MainAssetCollector).ToArray(); } /// @@ -173,7 +196,7 @@ namespace YooAsset.Editor AssetBundleBuild build = new AssetBundleBuild(); build.assetBundleName = BundleName; build.assetBundleVariant = string.Empty; - build.assetNames = GetBuildinAssetPaths(); + build.assetNames = GetAllMainAssetPaths(); return build; } diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportBundleInfo.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportBundleInfo.cs index 0f01cde..a4339ee 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportBundleInfo.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportBundleInfo.cs @@ -53,6 +53,11 @@ namespace YooAsset.Editor /// public int[] ReferenceIDs; + /// + /// 该资源包内包含的所有资源 + /// + public List AllBuiltinAssets = new List(); + /// /// 获取资源分类标签的字符串 /// diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyRawFile.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyRawFile.cs index eacf5f5..661af52 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyRawFile.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyRawFile.cs @@ -32,10 +32,10 @@ namespace YooAsset.Editor if (bundleInfo.IsRawFile) { string dest = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}"; - foreach (var buildAsset in bundleInfo.BuildinAssets) + foreach (var assetInfo in bundleInfo.AllMainAssets) { - if (buildAsset.IsRawAsset) - EditorTools.CopyFile(buildAsset.AssetPath, dest, true); + if (assetInfo.IsRawAsset) + EditorTools.CopyFile(assetInfo.AssetPath, dest, true); } } } diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateManifest.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateManifest.cs index d7d9433..310e36f 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateManifest.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateManifest.cs @@ -137,7 +137,7 @@ namespace YooAsset.Editor List result = new List(1000); foreach (var bundleInfo in buildMapContext.Collection) { - var assetInfos = bundleInfo.GetAllBuildAssetInfos(); + var assetInfos = bundleInfo.GetAllMainAssetInfos(); foreach (var assetInfo in assetInfos) { PackageAsset packageAsset = new PackageAsset(); diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs index 7f3a0cf..3b65c33 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs @@ -93,10 +93,11 @@ namespace YooAsset.Editor reportBundleInfo.FileHash = packageBundle.FileHash; reportBundleInfo.FileCRC = packageBundle.FileCRC; reportBundleInfo.FileSize = packageBundle.FileSize; - reportBundleInfo.Tags = packageBundle.Tags; - reportBundleInfo.ReferenceIDs = packageBundle.ReferenceIDs; reportBundleInfo.IsRawFile = packageBundle.IsRawFile; reportBundleInfo.LoadMethod = (EBundleLoadMethod)packageBundle.LoadMethod; + reportBundleInfo.Tags = packageBundle.Tags; + reportBundleInfo.ReferenceIDs = packageBundle.ReferenceIDs; + reportBundleInfo.AllBuiltinAssets = GetAllBuiltinAssets(buildMapContext, packageBundle.BundleName); buildReport.BundleInfos.Add(reportBundleInfo); } @@ -130,11 +131,11 @@ namespace YooAsset.Editor var bundleInfo = buildMapContext.GetBundleInfo(bundleName); { BuildAssetInfo findAssetInfo = null; - foreach (var buildinAsset in bundleInfo.BuildinAssets) + foreach (var assetInfo in bundleInfo.AllMainAssets) { - if (buildinAsset.AssetPath == assetPath) + if (assetInfo.AssetPath == assetPath) { - findAssetInfo = buildinAsset; + findAssetInfo = assetInfo; break; } } @@ -150,6 +151,15 @@ namespace YooAsset.Editor return result; } + /// + /// 获取该资源包内的所有资源(包括零依赖资源) + /// + private List GetAllBuiltinAssets(BuildMapContext buildMapContext, string bundleName) + { + var bundleInfo = buildMapContext.GetBundleInfo(bundleName); + return bundleInfo.GetAllBuiltinAssetPaths(); + } + private int GetMainAssetCount(PackageManifest manifest) { return manifest.AssetList.Count; diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs index 7a998a8..1e3dbe7 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs @@ -131,10 +131,10 @@ namespace YooAsset.Editor } // 10. 构建资源包 - var allBuildinAssets = buildAssetInfoDic.Values.ToList(); - if (allBuildinAssets.Count == 0) + var allPackAssets = buildAssetInfoDic.Values.ToList(); + if (allPackAssets.Count == 0) throw new Exception("构建的资源列表不能为空"); - foreach (var assetInfo in allBuildinAssets) + foreach (var assetInfo in allPackAssets) { context.PackAsset(assetInfo); } @@ -167,13 +167,13 @@ namespace YooAsset.Editor bool isRawFile = bundleInfo.IsRawFile; if (isRawFile) { - if (bundleInfo.BuildinAssets.Count != 1) + if (bundleInfo.AllMainAssets.Count != 1) throw new Exception($"The bundle does not support multiple raw asset : {bundleInfo.BundleName}"); continue; } // 注意:原生文件不能被其它资源文件依赖 - foreach (var assetInfo in bundleInfo.BuildinAssets) + foreach (var assetInfo in bundleInfo.AllMainAssets) { if (assetInfo.AllDependAssetInfos != null) {