100 lines
3.7 KiB
C#
100 lines
3.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using AlicizaX.Editor.Setting;
|
|
using AlicizaX;
|
|
using AlicizaX.UI.Runtime;
|
|
using Newtonsoft.Json;
|
|
using Sirenix.OdinInspector;
|
|
using UnityEngine;
|
|
using UnityEngine.Serialization;
|
|
|
|
namespace AlicizaX.UI.Editor
|
|
{
|
|
[AlicizaX.Editor.Setting.FilePath("ProjectSettings/UIGenerateConfiguration.asset")]
|
|
internal class UIGenerateConfiguration : ScriptableSingleton<UIGenerateConfiguration>
|
|
{
|
|
public UIGenerateCommonData UIGenerateCommonData = new UIGenerateCommonData();
|
|
public UIScriptGenerateConfig UIScriptGenerateConfig = new UIScriptGenerateConfig();
|
|
public List<UIEelementRegexData> UIElementRegexConfigs = new List<UIEelementRegexData>();
|
|
}
|
|
|
|
[System.Serializable]
|
|
public class UIGenerateCommonData
|
|
{
|
|
[LabelText("组件检查分隔符")] public string ComCheckSplitName = "#";
|
|
[LabelText("组件结尾分隔符")] public string ComCheckEndName = "@";
|
|
[LabelText("数组组件检查分隔符")] public string ArrayComSplitName = "*";
|
|
[LabelText("生成脚本前缀")] public string GeneratePrefix = "ui";
|
|
[LabelText("排除表")] public string[] ExcludeKeywords = { "ViewHolder" };
|
|
|
|
[ShowInInspector] [LabelText("生成路径拼接")]
|
|
public Dictionary<string, string> CombineWords = new Dictionary<string, string>
|
|
{
|
|
{ "Window", "Window" },
|
|
{ "ViewHolder", "ViewHolder" },
|
|
{ "Widget", "Widget" },
|
|
};
|
|
}
|
|
|
|
[System.Serializable]
|
|
public 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.Utility.Assembly.GetTypes()
|
|
.Where(m => !m.FullName.Contains("Editor"))
|
|
.Where(x => !x.IsAbstract || x.IsInterface)
|
|
.Where(x => !x.IsGenericTypeDefinition)
|
|
.Where(x => !x.IsSubclassOf(typeof(UIHolderObjectBase)))
|
|
.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.Name).ToList();
|
|
|
|
cacheFilterType.Add(typeof(GameObject).Name);
|
|
}
|
|
|
|
return cacheFilterType;
|
|
}
|
|
}
|
|
|
|
|
|
[System.Serializable]
|
|
public class UIScriptGenerateConfig
|
|
{
|
|
[BoxGroup("主工程")] public UIScriptGenerateData MainProjectUIScriptGenerateData = new UIScriptGenerateData();
|
|
[BoxGroup("热更工程")] public UIScriptGenerateData HotFixProjectUIScriptGenerateData = new UIScriptGenerateData();
|
|
}
|
|
|
|
[System.Serializable]
|
|
public class UIScriptGenerateData
|
|
{
|
|
public string NameSpace;
|
|
|
|
[Sirenix.OdinInspector.FolderPath(RequireExistingPath = true, AbsolutePath = false)]
|
|
public string GenerateHolderCodePath;
|
|
|
|
[Sirenix.OdinInspector.FolderPath(RequireExistingPath = true, AbsolutePath = false)]
|
|
public string UIPrefabRootPath;
|
|
|
|
public EUIResLoadType LoadType;
|
|
}
|
|
}
|