From 8f8b1f1dc5028c7c3099513c82f81b77115775eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20=C4=90=E1=BB=A9c=20Long?= Date: Mon, 26 Sep 2022 18:41:33 +0700 Subject: [PATCH] [Enhance] Prioritize node created from assets --- .../Editor/Views/BaseGraphView.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Assets/com.alelievr.NodeGraphProcessor/Editor/Views/BaseGraphView.cs b/Assets/com.alelievr.NodeGraphProcessor/Editor/Views/BaseGraphView.cs index 7940f6ee..7c2c3dd4 100644 --- a/Assets/com.alelievr.NodeGraphProcessor/Editor/Views/BaseGraphView.cs +++ b/Assets/com.alelievr.NodeGraphProcessor/Editor/Views/BaseGraphView.cs @@ -133,7 +133,15 @@ protected NodeInspectorObject nodeInspector public SerializedObject serializedGraph { get; private set; } - Dictionary nodeTypePerCreateAssetType = new Dictionary(); + SortedDictionary nodeTypePerCreateAssetType = new SortedDictionary( + // Sort by order of inheritances, so that the descendant type is prioritized over the ascendant type. + // Otherwise, sort by name. + Comparer.Create((Type x, Type y) => { + if (x.IsSubclassOf(y)) return -1; + else if (y.IsSubclassOf(x)) return 1; + else return x.FullName.CompareTo(y.FullName); + }) + ); public BaseGraphView(EditorWindow window) {