From 192b60f037f2d72d8b40288a4889adb2415c8c8b Mon Sep 17 00:00:00 2001 From: hevinci Date: Tue, 21 Mar 2023 19:35:01 +0800 Subject: [PATCH] update asset bundle collector MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复了GroupActiveRule保存无效的问题。 --- .../AssetBundleCollectorConfig.cs | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorConfig.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorConfig.cs index 9c43cfe..e9be8a2 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 = "2.3"; + public const string ConfigVersion = "2.4"; public const string XmlVersion = "Version"; public const string XmlCommon = "Common"; @@ -24,6 +24,7 @@ namespace YooAsset.Editor public const string XmlPackageDesc = "PackageDesc"; public const string XmlGroup = "Group"; + public const string XmlGroupActiveRule = "GroupActiveRule"; public const string XmlGroupName = "GroupName"; public const string XmlGroupDesc = "GroupDesc"; @@ -108,6 +109,8 @@ namespace YooAsset.Editor foreach (var groupNode in groupNodeList) { XmlElement groupElement = groupNode as XmlElement; + if (groupElement.HasAttribute(XmlGroupActiveRule) == false) + throw new Exception($"Not found attribute {XmlGroupActiveRule} in {XmlGroup}"); if (groupElement.HasAttribute(XmlGroupName) == false) throw new Exception($"Not found attribute {XmlGroupName} in {XmlGroup}"); if (groupElement.HasAttribute(XmlGroupDesc) == false) @@ -116,6 +119,7 @@ namespace YooAsset.Editor throw new Exception($"Not found attribute {XmlAssetTags} in {XmlGroup}"); AssetBundleCollectorGroup group = new AssetBundleCollectorGroup(); + group.ActiveRuleName = groupElement.GetAttribute(XmlGroupActiveRule); group.GroupName = groupElement.GetAttribute(XmlGroupName); group.GroupDesc = groupElement.GetAttribute(XmlGroupDesc); group.AssetTags = groupElement.GetAttribute(XmlAssetTags); @@ -208,6 +212,7 @@ namespace YooAsset.Editor foreach (var group in package.Groups) { var groupElement = xmlDoc.CreateElement(XmlGroup); + groupElement.SetAttribute(XmlGroupActiveRule, group.ActiveRuleName); groupElement.SetAttribute(XmlGroupName, group.GroupName); groupElement.SetAttribute(XmlGroupDesc, group.GroupDesc); groupElement.SetAttribute(XmlAssetTags, group.AssetTags); @@ -347,6 +352,23 @@ namespace YooAsset.Editor return UpdateXmlConfig(xmlDoc); } + // 2.3 -> 2.4 + if(configVersion == "2.3") + { + // 获取所有分组元素 + var groupNodeList = root.GetElementsByTagName(XmlGroup); + foreach (var groupNode in groupNodeList) + { + XmlElement groupElement = groupNode as XmlElement; + if(groupElement.HasAttribute(XmlGroupActiveRule) == false) + groupElement.SetAttribute(XmlGroupActiveRule, $"{nameof(EnableGroup)}"); + } + + // 更新版本 + root.SetAttribute(XmlVersion, "2.4"); + return UpdateXmlConfig(xmlDoc); + } + return false; } }