From f711d7eca124441645b295c9002c52f8a60662b4 Mon Sep 17 00:00:00 2001 From: hevinci Date: Sun, 3 Apr 2022 13:00:45 +0800 Subject: [PATCH] Update AssetBundleGrouper --- .../AssetBundleGrouper/AssetBundleCollector.cs | 4 ++-- .../Editor/AssetBundleGrouper/DefaultFilterRule.cs | 14 +++++++------- .../Editor/AssetBundleGrouper/IFilterRule.cs | 13 +++++++++++-- .../Editor/AssetBundleGrouper/IPackRule.cs | 3 --- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/Assets/YooAsset/Editor/AssetBundleGrouper/AssetBundleCollector.cs b/Assets/YooAsset/Editor/AssetBundleGrouper/AssetBundleCollector.cs index b2eec3f..ba62b63 100644 --- a/Assets/YooAsset/Editor/AssetBundleGrouper/AssetBundleCollector.cs +++ b/Assets/YooAsset/Editor/AssetBundleGrouper/AssetBundleCollector.cs @@ -40,7 +40,7 @@ namespace YooAsset.Editor /// public void CheckConfigError() { - if(AssetDatabase.LoadAssetAtPath(CollectPath) == null) + if (AssetDatabase.LoadAssetAtPath(CollectPath) == null) throw new Exception($"Invalid collect path : {CollectPath}"); if (AssetBundleGrouperSettingData.HasPackRuleName(PackRuleName) == false) @@ -137,7 +137,7 @@ namespace YooAsset.Editor // 根据规则设置过滤资源文件 IFilterRule filterRuleInstance = AssetBundleGrouperSettingData.GetFilterRuleInstance(FilterRuleName); - return filterRuleInstance.IsCollectAsset(assetPath); + return filterRuleInstance.IsCollectAsset(new FilterRuleData(assetPath)); } private string GetBundleName(AssetBundleGrouper grouper, string assetPath) { diff --git a/Assets/YooAsset/Editor/AssetBundleGrouper/DefaultFilterRule.cs b/Assets/YooAsset/Editor/AssetBundleGrouper/DefaultFilterRule.cs index 95adedb..2141774 100644 --- a/Assets/YooAsset/Editor/AssetBundleGrouper/DefaultFilterRule.cs +++ b/Assets/YooAsset/Editor/AssetBundleGrouper/DefaultFilterRule.cs @@ -9,7 +9,7 @@ namespace YooAsset.Editor /// public class CollectAll : IFilterRule { - public bool IsCollectAsset(string assetPath) + public bool IsCollectAsset(FilterRuleData data) { return true; } @@ -20,9 +20,9 @@ namespace YooAsset.Editor /// public class CollectScene : IFilterRule { - public bool IsCollectAsset(string assetPath) + public bool IsCollectAsset(FilterRuleData data) { - return Path.GetExtension(assetPath) == ".unity"; + return Path.GetExtension(data.AssetPath) == ".unity"; } } @@ -31,9 +31,9 @@ namespace YooAsset.Editor /// public class CollectPrefab : IFilterRule { - public bool IsCollectAsset(string assetPath) + public bool IsCollectAsset(FilterRuleData data) { - return Path.GetExtension(assetPath) == ".prefab"; + return Path.GetExtension(data.AssetPath) == ".prefab"; } } @@ -42,9 +42,9 @@ namespace YooAsset.Editor /// public class CollectSprite : IFilterRule { - public bool IsCollectAsset(string assetPath) + public bool IsCollectAsset(FilterRuleData data) { - if (AssetDatabase.GetMainAssetTypeAtPath(assetPath) == typeof(Sprite)) + if (AssetDatabase.GetMainAssetTypeAtPath(data.AssetPath) == typeof(Sprite)) return true; else return false; diff --git a/Assets/YooAsset/Editor/AssetBundleGrouper/IFilterRule.cs b/Assets/YooAsset/Editor/AssetBundleGrouper/IFilterRule.cs index 80b5972..1e36e8a 100644 --- a/Assets/YooAsset/Editor/AssetBundleGrouper/IFilterRule.cs +++ b/Assets/YooAsset/Editor/AssetBundleGrouper/IFilterRule.cs @@ -1,6 +1,16 @@  namespace YooAsset.Editor { + public struct FilterRuleData + { + public string AssetPath; + + public FilterRuleData(string assetPath) + { + AssetPath = assetPath; + } + } + /// /// 资源过滤规则接口 /// @@ -9,8 +19,7 @@ namespace YooAsset.Editor /// /// 是否为收集资源 /// - /// 资源路径 /// 如果收集该资源返回TRUE - bool IsCollectAsset(string assetPath); + bool IsCollectAsset(FilterRuleData data); } } \ No newline at end of file diff --git a/Assets/YooAsset/Editor/AssetBundleGrouper/IPackRule.cs b/Assets/YooAsset/Editor/AssetBundleGrouper/IPackRule.cs index 3a12c74..db7d791 100644 --- a/Assets/YooAsset/Editor/AssetBundleGrouper/IPackRule.cs +++ b/Assets/YooAsset/Editor/AssetBundleGrouper/IPackRule.cs @@ -1,9 +1,6 @@  namespace YooAsset.Editor { - /// - /// 打包规则数据 - /// public struct PackRuleData { public string AssetPath;