Skip to content

Commit 64779ef

Browse files
committed
apply upstream PRs alelievr#232 and alelievr#222; bump version to 1.4.1
- Make BaseGraphView.CanConnectEdge virtual (upstream alelievr#232), so subclasses can override edge-connection validation without forking. - Change nodeTypePerCreateAssetType to a SortedDictionary with a subclass-priority comparer (upstream alelievr#222), so dragging an asset whose type has multiple matching ICreateNodeFrom<T> implementations picks the most derived one instead of an arbitrary insertion-order match.
1 parent 8b1f2b5 commit 64779ef

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,15 @@ protected NodeInspectorObject nodeInspector
133133

134134
HashSet<BaseNodeView> selectionScratchSet = new HashSet<BaseNodeView>();
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
{
@@ -1182,7 +1190,7 @@ public void RemoveGroups()
11821190
groupViews.Clear();
11831191
}
11841192

1185-
public bool CanConnectEdge(EdgeView e, bool autoDisconnectInputs = true)
1193+
public virtual bool CanConnectEdge(EdgeView e, bool autoDisconnectInputs = true)
11861194
{
11871195
if (e.input == null || e.output == null)
11881196
return false;

Assets/com.dyonng.NodeGraphProcessor/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "com.dyonng.node-graph-processor",
33
"displayName": "Node Graph Processor",
4-
"version": "1.4.0",
4+
"version": "1.4.1",
55
"unity": "6000.5",
66
"description": "Node graph editor framework focused on data processing using Unity UIElements and C# 4.7",
77
"keywords": [

0 commit comments

Comments
 (0)