From 3a81d7babdbc3d405dbbecf4b29f0847abfe4b8a Mon Sep 17 00:00:00 2001 From: hevinci Date: Wed, 7 Dec 2022 17:52:02 +0800 Subject: [PATCH] update editor logic --- .../AssetBundleCollector.cs | 4 +-- .../AssetBundleCollectorConfig.cs | 2 +- .../AssetBundleCollectorPackage.cs | 4 +-- .../AssetBundleCollectorWindow.cs | 2 +- Assets/YooAsset/Editor/EditorTools.cs | 29 +++++++++++++++++++ 5 files changed, 35 insertions(+), 6 deletions(-) diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs index 292ed67..ece39f6 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs @@ -297,8 +297,8 @@ namespace YooAsset.Editor } private List GetAssetTags(AssetBundleCollectorGroup group) { - List tags = StringUtility.StringToStringList(group.AssetTags, ';'); - List temper = StringUtility.StringToStringList(AssetTags, ';'); + List tags = EditorTools.StringToStringList(group.AssetTags, ';'); + List temper = EditorTools.StringToStringList(AssetTags, ';'); tags.AddRange(temper); return tags; } diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorConfig.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorConfig.cs index 6558d8d..1996b0a 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorConfig.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorConfig.cs @@ -143,7 +143,7 @@ namespace YooAsset.Editor AssetBundleCollector collector = new AssetBundleCollector(); collector.CollectPath = collectorElement.GetAttribute(XmlCollectPath); collector.CollectorGUID = collectorElement.GetAttribute(XmlCollectorGUID); - collector.CollectorType = StringUtility.NameToEnum(collectorElement.GetAttribute(XmlCollectorType)); + collector.CollectorType = EditorTools.NameToEnum(collectorElement.GetAttribute(XmlCollectorType)); collector.AddressRuleName = collectorElement.GetAttribute(XmlAddressRule); collector.PackRuleName = collectorElement.GetAttribute(XmlPackRule); collector.FilterRuleName = collectorElement.GetAttribute(XmlFilterRule); diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorPackage.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorPackage.cs index 7815973..df6a8f2 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorPackage.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorPackage.cs @@ -102,7 +102,7 @@ namespace YooAsset.Editor HashSet result = new HashSet(); foreach (var group in Groups) { - List groupTags = StringUtility.StringToStringList(group.AssetTags, ';'); + List groupTags = EditorTools.StringToStringList(group.AssetTags, ';'); foreach (var tag in groupTags) { if (result.Contains(tag) == false) @@ -111,7 +111,7 @@ namespace YooAsset.Editor foreach (var collector in group.Collectors) { - List collectorTags = StringUtility.StringToStringList(collector.AssetTags, ';'); + List collectorTags = EditorTools.StringToStringList(collector.AssetTags, ';'); foreach (var tag in collectorTags) { if (result.Contains(tag) == false) diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs index ec5ea68..486ce7e 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs @@ -694,7 +694,7 @@ namespace YooAsset.Editor popupField0.index = GetCollectorTypeIndex(collector.CollectorType.ToString()); popupField0.RegisterValueChangedCallback(evt => { - collector.CollectorType = StringUtility.NameToEnum(evt.newValue); + collector.CollectorType = EditorTools.NameToEnum(evt.newValue); AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector); if (foldout.value) { diff --git a/Assets/YooAsset/Editor/EditorTools.cs b/Assets/YooAsset/Editor/EditorTools.cs index 8effd8e..8b33a51 100644 --- a/Assets/YooAsset/Editor/EditorTools.cs +++ b/Assets/YooAsset/Editor/EditorTools.cs @@ -285,6 +285,35 @@ namespace YooAsset.Editor } #endregion + #region StringUtility + public static List StringToStringList(string str, char separator) + { + List result = new List(); + if (!String.IsNullOrEmpty(str)) + { + string[] splits = str.Split(separator); + foreach (string split in splits) + { + string value = split.Trim(); //移除首尾空格 + if (!String.IsNullOrEmpty(value)) + { + result.Add(value); + } + } + } + return result; + } + + public static T NameToEnum(string name) + { + if (Enum.IsDefined(typeof(T), name) == false) + { + throw new ArgumentException($"Enum {typeof(T)} is not defined name {name}"); + } + return (T)Enum.Parse(typeof(T), name); + } + #endregion + #region 文件 /// /// 创建文件所在的目录