Skip to content

Commit 76cd680

Browse files
committed
[Enhance] Prioritize node created from assets
1 parent bc71d48 commit 76cd680

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Assets/com.alelievr.NodeGraphProcessor/Editor/Views/BaseGraphView.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,15 @@ protected NodeInspectorObject nodeInspector
133133

134134
public SerializedObject serializedGraph { get; private set; }
135135

136-
Dictionary<Type, (Type nodeType, MethodInfo initalizeNodeFromObject)> nodeTypePerCreateAssetType = new Dictionary<Type, (Type, MethodInfo)>();
136+
SortedDictionary<Type, (Type nodeType, MethodInfo initalizeNodeFromObject)> nodeTypePerCreateAssetType = new SortedDictionary<Type, (Type, MethodInfo)>(
137+
// Sort by order of inheritances, so that the descendant type is prioritized over the ascendant type.
138+
// Otherwise, sort by name.
139+
Comparer<Type>.Create((Type x, Type y) => {
140+
if (x.IsSubclassOf(y)) return -1;
141+
else if (y.IsSubclassOf(x)) return 1;
142+
else return x.FullName.CompareTo(y.FullName);
143+
})
144+
);
137145

138146
public BaseGraphView(EditorWindow window)
139147
{

0 commit comments

Comments
 (0)