From 0a709f741a4458e8a5b67770c94eaccefa8dd34f Mon Sep 17 00:00:00 2001 From: hevinci Date: Tue, 12 Mar 2024 11:12:13 +0800 Subject: [PATCH] feat : asset bundle collector config upgrade compatible --- .../AssetBundleCollectorConfig.cs | 19 ++++++++++++++++++- .../AssetBundleCollectorPackage.cs | 19 +++++++++++++++++++ .../AssetBundleCollectorSettingData.cs | 1 + .../AssetBundleCollectorWindow.uxml | 1 - 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorConfig.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorConfig.cs index 25fef53..2412410 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorConfig.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorConfig.cs @@ -10,7 +10,7 @@ namespace YooAsset.Editor { public class AssetBundleCollectorConfig { - public const string ConfigVersion = "v2.0.0"; + public const string ConfigVersion = "v2.1"; public const string XmlVersion = "Version"; public const string XmlCommon = "Common"; @@ -258,6 +258,23 @@ namespace YooAsset.Editor if (configVersion == ConfigVersion) return true; + // v2.0.0 -> v2.1 + if (configVersion == "v2.0.0") + { + // 读取包裹配置 + var packageNodeList = root.GetElementsByTagName(XmlPackage); + foreach (var packageNode in packageNodeList) + { + XmlElement packageElement = packageNode as XmlElement; + if (packageElement.HasAttribute(XmlIgnoreRuleName) == false) + packageElement.SetAttribute(XmlIgnoreRuleName, nameof(NormalIgnoreRule)); + } + + // 更新版本 + root.SetAttribute(XmlVersion, "v2.1"); + return UpdateXmlConfig(xmlDoc); + } + return false; } } diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorPackage.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorPackage.cs index a62cffb..4c8d7c8 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorPackage.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorPackage.cs @@ -56,6 +56,16 @@ namespace YooAsset.Editor /// public void CheckConfigError() { + if (string.IsNullOrEmpty(IgnoreRuleName)) + { + throw new Exception($"{nameof(IgnoreRuleName)} is null or empty !"); + } + else + { + if (AssetBundleCollectorSettingData.HasIgnoreRuleName(IgnoreRuleName) == false) + throw new Exception($"Invalid {nameof(IIgnoreRule)} class type : {IgnoreRuleName} in package : {PackageName}"); + } + foreach (var group in Groups) { group.CheckConfigError(); @@ -68,6 +78,14 @@ namespace YooAsset.Editor public bool FixConfigError() { bool isFixed = false; + + if (string.IsNullOrEmpty(IgnoreRuleName)) + { + Debug.LogWarning($"Set the {nameof(IgnoreRuleName)} to {nameof(NormalIgnoreRule)}"); + IgnoreRuleName = nameof(NormalIgnoreRule); + isFixed = true; + } + foreach (var group in Groups) { if (group.FixConfigError()) @@ -75,6 +93,7 @@ namespace YooAsset.Editor isFixed = true; } } + return isFixed; } diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs index e8f4fe4..c0c41a2 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs @@ -191,6 +191,7 @@ namespace YooAsset.Editor if (isFixed) { IsDirty = true; + Debug.Log("Fix package config error done !"); } } diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.uxml b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.uxml index 3085972..19112af 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.uxml +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.uxml @@ -21,7 +21,6 @@ -