AlicizaX/Client/Packages/com.alicizax.unity.ui/Editor/UIConfig/UIGenerateGlobalSettings.cs
2025-01-26 20:55:39 +08:00

86 lines
3.1 KiB
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using AlicizaX.Runtime;
using Sirenix.OdinInspector;
using UnityEditor;
using UnityEngine;
namespace AlicizaX.UI.Editor
{
internal class UIGenerateGlobalSettings : ScriptableObject
{
[TabGroup("UI构建配置")] [TableList(ShowIndexLabels = false, DrawScrollView = true, AlwaysExpanded = true)] [SerializeField]
public List<UIScriptGenerateData> UIScriptGenerateConfigs = new List<UIScriptGenerateData>();
[TabGroup("UI元素映射1")] [TableList(ShowIndexLabels = false, DrawScrollView = true, AlwaysExpanded = true)] [SerializeField]
public List<ScriptGenerateRuler> scriptGenerateRule = new List<ScriptGenerateRuler>();
[TabGroup("UI元素映射2")] [TableList(ShowIndexLabels = false, DrawScrollView = true, AlwaysExpanded = true)] [SerializeField]
public List<UIEelementRegexData> UIElementRegexConfigs = new List<UIEelementRegexData>();
}
[Serializable]
internal class ScriptGenerateRuler
{
public string uiElementRegex;
public string componentName;
public ScriptGenerateRuler(string uiElementRegex, string componentName)
{
this.uiElementRegex = uiElementRegex;
this.componentName = componentName;
}
}
[System.Serializable]
internal class UIEelementRegexData
{
public string uiElementRegex;
[ShowInInspector] [ValueDropdown("GetFilteredTypeList", ExpandAllMenuItems = false)]
public string componentType;
private static List<string> cacheFilterType;
public IEnumerable<string> GetFilteredTypeList()
{
if (cacheFilterType == null)
{
cacheFilterType = AlicizaX.Runtime.Utility.Assembly.GetTypes()
.Where(m => !m.FullName.Contains("Editor"))
.Where(x => !x.IsAbstract || x.IsInterface)
.Where(x => !x.IsGenericTypeDefinition)
.Where(x => !x.IsSubclassOf(typeof(GameFrameworkComponent)))
.Where(x => x.IsSubclassOf(typeof(Component)))
.Where(x => !x.FullName.Contains("YooAsset"))
.Where(x => !x.FullName.Contains(("Unity.VisualScripting")))
.Where(x => !x.FullName.Contains(("Cysharp.Threading")))
.Where(x => !x.FullName.Contains(("UnityEngine.Rendering.UI.Debug")))
.Where(x => !x.FullName.Contains(("Unity.PerformanceTesting")))
.Where(x => !x.FullName.Contains(("UnityEngine.TestTools")))
.Select(x => x.FullName).ToList();
cacheFilterType.Add(typeof(GameObject).FullName);
}
return cacheFilterType;
}
}
[System.Serializable]
internal class UIScriptGenerateData
{
public string ConfigName;
[Sirenix.OdinInspector.FolderPath(RequireExistingPath = true, AbsolutePath = false)]
public string GenerateCodePath;
[Sirenix.OdinInspector.FolderPath(RequireExistingPath = true, AbsolutePath = false)]
public string UIPrefabPath;
}
}