Skip to content

Commit d44b01f

Browse files
author
Daniel Burgess
committed
BUG SubGraph edges persist when they don't exist
When resetting a SubGraph's Schema edges that should be removed stay
1 parent a43351f commit d44b01f

File tree

5 files changed

+54
-38
lines changed

5 files changed

+54
-38
lines changed

Assets/Examples/BasicExample.asset

+33-22
Original file line numberDiff line numberDiff line change
@@ -65,29 +65,40 @@ MonoBehaviour:
6565
inputPortIdentifier:
6666
outputPortIdentifier:
6767
- _guid:
68-
Value: 4134c8f0-3dd1-4b20-836e-afb4762a92c8
68+
Value: abe45722-8a31-4cc1-be33-d3b8a90b5c1a
6969
owner: {fileID: 11400000}
7070
inputNodeGUID:
71-
Value: 05c6ea81-f327-4692-9e0f-792c109f3184
71+
Value: 034f0a6d-ea56-4e83-8190-5459f04085bf
7272
outputNodeGUID:
7373
Value: 2d09ddaf-923b-4f10-9ea7-a279c757ea26
7474
inputFieldName: _ingress
7575
outputFieldName: output
7676
inputPortIdentifier: Float IN
7777
outputPortIdentifier:
7878
- _guid:
79-
Value: 604145ea-745c-4b4b-9ccc-c089dc173c95
79+
Value: 0e58fe31-0e18-47ec-9e66-772ca7d7a543
8080
owner: {fileID: 11400000}
8181
inputNodeGUID:
82-
Value: b233fdec-4d0e-48e2-a2d9-bb976eb6f6f3
82+
Value: f1bbd92e-6021-4bfb-9420-a3cc973fbb0d
8383
outputNodeGUID:
84-
Value: 05c6ea81-f327-4692-9e0f-792c109f3184
84+
Value: 034f0a6d-ea56-4e83-8190-5459f04085bf
8585
inputFieldName: obj
8686
outputFieldName: _egress
8787
inputPortIdentifier:
8888
outputPortIdentifier: String OUT
8989
- _guid:
90-
Value: 326496ae-9ef5-44e4-a475-b9e602f1f695
90+
Value: eec4286d-0123-4afd-b207-f7b8294a4a02
91+
owner: {fileID: 11400000}
92+
inputNodeGUID:
93+
Value: 034f0a6d-ea56-4e83-8190-5459f04085bf
94+
outputNodeGUID:
95+
Value: 87d938a8-54f3-4391-aad4-abf499ae38b4
96+
inputFieldName: _ingress
97+
outputFieldName: output
98+
inputPortIdentifier: Decimal Places
99+
outputPortIdentifier: output
100+
- _guid:
101+
Value: c8cb5412-1b74-4cea-8c0a-a03b10f7dcaa
91102
owner: {fileID: 11400000}
92103
inputNodeGUID:
93104
Value: 034f0a6d-ea56-4e83-8190-5459f04085bf
@@ -98,27 +109,27 @@ MonoBehaviour:
98109
inputPortIdentifier: Float IN
99110
outputPortIdentifier:
100111
- _guid:
101-
Value: 91ea98d1-763d-4b47-8d7d-8dbe42d915f9
112+
Value: 3245c8d4-ed87-4397-a4fa-f623440c641a
102113
owner: {fileID: 11400000}
103114
inputNodeGUID:
104-
Value: f1bbd92e-6021-4bfb-9420-a3cc973fbb0d
115+
Value: 05c6ea81-f327-4692-9e0f-792c109f3184
105116
outputNodeGUID:
106-
Value: 034f0a6d-ea56-4e83-8190-5459f04085bf
107-
inputFieldName: obj
108-
outputFieldName: _egress
109-
inputPortIdentifier:
110-
outputPortIdentifier: String OUT
117+
Value: 2d09ddaf-923b-4f10-9ea7-a279c757ea26
118+
inputFieldName: _ingress
119+
outputFieldName: output
120+
inputPortIdentifier: Float IN
121+
outputPortIdentifier:
111122
- _guid:
112-
Value: e8dcd9f4-b743-4eda-a990-a09c466e00fa
123+
Value: 9d4de727-b267-4c5b-b92a-ea85f72633bf
113124
owner: {fileID: 11400000}
114125
inputNodeGUID:
115-
Value: 034f0a6d-ea56-4e83-8190-5459f04085bf
126+
Value: b233fdec-4d0e-48e2-a2d9-bb976eb6f6f3
116127
outputNodeGUID:
117-
Value: 87d938a8-54f3-4391-aad4-abf499ae38b4
118-
inputFieldName: _ingress
119-
outputFieldName: output
120-
inputPortIdentifier: Decimal Places
121-
outputPortIdentifier: output
128+
Value: 05c6ea81-f327-4692-9e0f-792c109f3184
129+
inputFieldName: obj
130+
outputFieldName: _egress
131+
inputPortIdentifier:
132+
outputPortIdentifier: String OUT
122133
groups:
123134
- title: New Comment Block
124135
color: {r: 0, g: 0, b: 0, a: 0}
@@ -1248,7 +1259,7 @@ MonoBehaviour:
12481259
- rid: 4827994175793266935
12491260
type: {class: SubGraphNode, ns: , asm: com.alelievr.NodeGraphProcessor.Runtime}
12501261
data:
1251-
nodeCustomName:
1262+
nodeCustomName: Float To String
12521263
_guid:
12531264
Value: 05c6ea81-f327-4692-9e0f-792c109f3184
12541265
computeOrder: 10
@@ -1300,7 +1311,7 @@ MonoBehaviour:
13001311
computeOrder: 31
13011312
position:
13021313
serializedVersion: 2
1303-
x: -535.0001
1314+
x: -535
13041315
y: 1031.5
13051316
width: 125
13061317
height: 37

Assets/Examples/FloatToString.asset

+7-7
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ MonoBehaviour:
1919
- rid: 4827994175793266725
2020
edges:
2121
- _guid:
22-
Value: 9b4d0bb9-965b-43a5-9a7b-9cd00344d029
22+
Value: 6c633c2e-ccc0-4b60-b504-734e85a9054b
2323
owner: {fileID: 11400000}
2424
inputNodeGUID:
2525
Value: 7a64e6db-4a2a-4a0f-920e-45ac493ae39f
@@ -30,7 +30,7 @@ MonoBehaviour:
3030
inputPortIdentifier:
3131
outputPortIdentifier: Float IN
3232
- _guid:
33-
Value: 0245cd7d-8811-4048-9d6a-fa26bc67cde6
33+
Value: 6b771e34-f0f7-4080-92ce-4101464e233c
3434
owner: {fileID: 11400000}
3535
inputNodeGUID:
3636
Value: ea9dd183-58e9-46d0-b544-e999ef6808ab
@@ -51,7 +51,7 @@ MonoBehaviour:
5151
scale: {x: 1.7490063, y: 1.7490063, z: 1}
5252
options:
5353
displayName: Float To String
54-
renamePolicy: 2
54+
renamePolicy: 1
5555
isMacro: 0
5656
macroOptions:
5757
menuLocation:
@@ -70,8 +70,8 @@ MonoBehaviour:
7070
computeOrder: 0
7171
position:
7272
serializedVersion: 2
73-
x: 535.4502
74-
y: 464.75006
73+
x: 605.6925
74+
y: 441.00006
7575
width: 84
7676
height: 75
7777
initialPosition:
@@ -92,8 +92,8 @@ MonoBehaviour:
9292
computeOrder: 2
9393
position:
9494
serializedVersion: 2
95-
x: 1030.4501
96-
y: 488.00006
95+
x: 957.1414
96+
y: 441.0001
9797
width: 98
9898
height: 75
9999
initialPosition:

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

+1-4
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,6 @@ public void UpdatePortView(PortData data)
194194
UpdatePortSize();
195195
}
196196

197-
public List<EdgeView> GetEdges()
198-
{
199-
return edges;
200-
}
197+
public List<EdgeView> GetEdges() => edges;
201198
}
202199
}

Assets/com.alelievr.NodeGraphProcessor/Runtime/Graph/BaseGraph.cs

+12-5
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ protected virtual void OnEnable()
178178

179179
public virtual void Initialize() { }
180180

181-
void InitializeGraphElements()
181+
private void InitializeGraphElements()
182182
{
183183
// Sanitize the element lists (it's possible that nodes are null if their full class name have changed)
184184
// If you rename / change the assembly of a node or parameter, please use the MovedFrom() attribute to avoid breaking the graph.
@@ -815,14 +815,21 @@ void PropagateComputeOrder(BaseNode node, int computeOrder)
815815
}
816816
}
817817

818-
void DestroyBrokenGraphElements()
818+
protected void DestroyBrokenGraphElements()
819819
{
820-
edges.RemoveAll(e => e.inputNode == null
820+
var brokenEdges = edges.FindAll(e => e.inputNode == null
821821
|| e.outputNode == null
822+
|| !e.inputNode.GetAllEdges().Contains(e)
823+
|| !e.outputNode.GetAllEdges().Contains(e)
822824
|| string.IsNullOrEmpty(e.outputFieldName)
823-
|| string.IsNullOrEmpty(e.inputFieldName)
824-
);
825+
|| string.IsNullOrEmpty(e.inputFieldName));
826+
827+
brokenEdges.ForEach(e => Disconnect(e.GUID));
828+
edges.RemoveAll(e => brokenEdges.Contains(e));
829+
825830
nodes.RemoveAll(n => n == null);
831+
832+
UpdateComputeOrder();
826833
}
827834

828835
/// <summary>

Assets/com.alelievr.NodeGraphProcessor/Runtime/Graph/SubGraph.cs

+1
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ public void RemoveOptionsListener(Notify listener)
137137
public void NotifyPortsChanged()
138138
{
139139
OnPortsUpdated?.Invoke();
140+
DestroyBrokenGraphElements();
140141
}
141142

142143
public void NotifyOptionsChanged()

0 commit comments

Comments
 (0)