From 0aa9e4f666b4a86137ceb730e970d747e3900a6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=80=9D=E6=B5=B7?= <1464576565@qq.com> Date: Fri, 14 Nov 2025 20:52:00 +0800 Subject: [PATCH] 1 --- Editor/Graph/SearchWindowProvider.cs | 52 +++++++++++++++++++--------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/Editor/Graph/SearchWindowProvider.cs b/Editor/Graph/SearchWindowProvider.cs index ea402ef..98eea84 100644 --- a/Editor/Graph/SearchWindowProvider.cs +++ b/Editor/Graph/SearchWindowProvider.cs @@ -6,13 +6,16 @@ using UnityEditor.Experimental.GraphView; using UnityEngine; using UnityEngine.UIElements; -namespace AlicizaX.AnimationFlow.Editor { - public class SearchWindowProvider : ScriptableObject, ISearchWindowProvider { +namespace AlicizaX.AnimationFlow.Editor +{ + public class SearchWindowProvider : ScriptableObject, ISearchWindowProvider + { private GraphWindow graphWindow; private GraphView graphView; private Texture2D icon; - public void Initialize(GraphWindow graphWindow, GraphView graphView) { + public void Initialize(GraphWindow graphWindow, GraphView graphView) + { this.graphWindow = graphWindow; this.graphView = graphView; icon = new Texture2D(1, 1); @@ -20,39 +23,56 @@ namespace AlicizaX.AnimationFlow.Editor { icon.Apply(); } - List ISearchWindowProvider.CreateSearchTree(SearchWindowContext context) { - List entries = new() { - new SearchTreeGroupEntry(new GUIContent("Create Node",icon)) + List ISearchWindowProvider.CreateSearchTree(SearchWindowContext context) + { + List entries = new() + { + new SearchTreeGroupEntry(new GUIContent("Create Node", icon)) }; Dictionary> dicType = new(); - foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { - foreach (var type in assembly.GetTypes()) { - if (type.IsClass && !type.IsAbstract && type.IsSubclassOf(typeof(ActionNode))) { + foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) + { + if (assembly.FullName.Contains("Sirenix")) continue; + foreach (var type in assembly.GetTypes()) + { + if (type.IsClass && !type.IsAbstract && type.IsSubclassOf(typeof(ActionNode))) + { CategoryAttribute categoryAttribute = type.GetCustomAttributes(typeof(CategoryAttribute), true).FirstOrDefault() as CategoryAttribute; - if (categoryAttribute == null || string.IsNullOrEmpty(categoryAttribute.category)) { + if (categoryAttribute == null || string.IsNullOrEmpty(categoryAttribute.category)) + { NameAttribute nameAttribute = type.GetCustomAttributes(typeof(NameAttribute), true).FirstOrDefault() as NameAttribute; entries.Add(new SearchTreeEntry(new GUIContent(nameAttribute != null && !string.IsNullOrEmpty(nameAttribute.name) ? nameAttribute.name : type.Name, icon)) { level = 1, userData = type }); - } else { - if (dicType.TryGetValue(categoryAttribute.category, out var list)) { + } + else + { + if (dicType.TryGetValue(categoryAttribute.category, out var list)) + { list.Add(type); - } else { + } + else + { dicType.Add(categoryAttribute.category, new List() { type }); } } } } } - foreach (var kv in dicType) { + + foreach (var kv in dicType) + { entries.Add(new SearchTreeGroupEntry(new GUIContent(kv.Key), 1)); - foreach (Type type in kv.Value) { + foreach (Type type in kv.Value) + { NameAttribute nameAttribute = type.GetCustomAttributes(typeof(NameAttribute), true).FirstOrDefault() as NameAttribute; entries.Add(new SearchTreeEntry(new GUIContent(nameAttribute != null && !string.IsNullOrEmpty(nameAttribute.name) ? nameAttribute.name : type.Name, icon)) { level = 2, userData = type }); } } + return entries; } - bool ISearchWindowProvider.OnSelectEntry(SearchTreeEntry searchTreeEntry, SearchWindowContext context) { + bool ISearchWindowProvider.OnSelectEntry(SearchTreeEntry searchTreeEntry, SearchWindowContext context) + { var type = searchTreeEntry.userData as Type; var data = Activator.CreateInstance(type) as ActionNode; data.uuid = Guid.NewGuid().ToString();