From bf92e6bf18f336d8367aac89ae2058c2ecfaacc3 Mon Sep 17 00:00:00 2001 From: hevinci Date: Thu, 17 Aug 2023 21:05:21 +0800 Subject: [PATCH] fix #130 --- .../BuildTasks/TaskGetBuildMap.cs | 2 +- .../AssetBundleCollectorSetting.cs | 53 +++++++++++-------- .../AssetBundleCollectorSettingData.cs | 2 +- 3 files changed, 32 insertions(+), 25 deletions(-) diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs index 2c32d93..b8554a6 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs @@ -33,7 +33,7 @@ namespace YooAsset.Editor Dictionary allBuildAssetInfoDic = new Dictionary(1000); // 1. 检测配置合法性 - AssetBundleCollectorSettingData.Setting.CheckConfigError(); + AssetBundleCollectorSettingData.Setting.CheckPackageConfigError(packageName); // 2. 获取所有收集器收集的资源 var collectResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(buildMode, packageName); diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs index b571851..069f870 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs @@ -61,9 +61,18 @@ namespace YooAsset.Editor } /// - /// 检测配置错误 + /// 检测包裹配置错误 /// - public void CheckConfigError() + public void CheckPackageConfigError(string packageName) + { + var package = GetPackage(packageName); + package.CheckConfigError(); + } + + /// + /// 检测所有配置错误 + /// + public void CheckAllPackageConfigError() { foreach (var package in Packages) { @@ -72,9 +81,9 @@ namespace YooAsset.Editor } /// - /// 修复配置错误 + /// 修复所有配置错误 /// - public bool FixConfigError() + public bool FixAllPackageConfigError() { bool isFixed = false; foreach (var package in Packages) @@ -92,16 +101,8 @@ namespace YooAsset.Editor /// public List GetPackageAllTags(string packageName) { - foreach (var package in Packages) - { - if (package.PackageName == packageName) - { - return package.GetAllTags(); - } - } - - Debug.LogWarning($"Not found package : {packageName}"); - return new List(); + var package = GetPackage(packageName); + return package.GetAllTags(); } /// @@ -112,19 +113,25 @@ namespace YooAsset.Editor if (string.IsNullOrEmpty(packageName)) throw new Exception("Build package name is null or mepty !"); + var package = GetPackage(packageName); + CollectCommand command = new CollectCommand(buildMode, packageName, + EnableAddressable, LocationToLower, IncludeAssetGUID, UniqueBundleName); + CollectResult collectResult = new CollectResult(command); + collectResult.SetCollectAssets(package.GetAllCollectAssets(command)); + return collectResult; + } + + /// + /// 获取包裹类 + /// + public AssetBundleCollectorPackage GetPackage(string packageName) + { foreach (var package in Packages) { if (package.PackageName == packageName) - { - CollectCommand command = new CollectCommand(buildMode, packageName, - EnableAddressable, LocationToLower, IncludeAssetGUID, UniqueBundleName); - CollectResult collectResult = new CollectResult(command); - collectResult.SetCollectAssets(package.GetAllCollectAssets(command)); - return collectResult; - } + return package; } - - throw new Exception($"Not found collector pacakge : {packageName}"); + throw new Exception($"Not found pacakge : {packageName}"); } } } \ No newline at end of file diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs index 7c8d34a..b29684c 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs @@ -161,7 +161,7 @@ namespace YooAsset.Editor /// public static void FixFile() { - bool isFixed = Setting.FixConfigError(); + bool isFixed = Setting.FixAllPackageConfigError(); if (isFixed) { IsDirty = true;