Skip to content

Commit b77a366

Browse files
committed
Fixed parameter node returning a wrong value
1 parent ed1ffe7 commit b77a366

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ public void Initialize(BaseGraphView owner, BaseNode node)
102102
this.RefreshPorts();
103103

104104
RegisterCallback<GeometryChangedEvent>(OnGeometryChanged);
105+
RegisterCallback<DetachFromPanelEvent>(e => ExceptionToLog.Call(Disable));
105106
OnGeometryChanged(null);
106107
}
107108

@@ -580,6 +581,8 @@ void ComputeOrderUpdatedCallback()
580581
public virtual void Enable(bool fromInspector = false) => DrawDefaultInspector(fromInspector);
581582
public virtual void Enable() => DrawDefaultInspector(false);
582583

584+
public virtual void Disable() {}
585+
583586
Dictionary<string, List<(object value, VisualElement target)>> visibleConditions = new Dictionary<string, List<(object value, VisualElement target)>>();
584587
Dictionary<string, VisualElement> hideElementIfConnected = new Dictionary<string, VisualElement>();
585588
Dictionary<FieldInfo, List<VisualElement>> fieldControlsMap = new Dictionary<FieldInfo, List<VisualElement>>();

Assets/com.alelievr.NodeGraphProcessor/Runtime/Elements/ParameterNode.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,14 @@ IEnumerable<PortData> GetInputPort(List<SerializableEdge> edges)
9191
}
9292
}
9393

94-
9594
protected override void Process()
9695
{
96+
#if UNITY_EDITOR // In the editor, an undo/redo can change the parameter instance in the graph, in this case the field in this class will point to the wrong parameter
97+
parameter = graph.GetExposedParameterFromGUID(parameterGUID);
98+
#endif
99+
97100
if (accessor == ParameterAccessor.Get)
98-
output = parameter?.value;
101+
output = parameter.value;
99102
else
100103
graph.UpdateExposedParameter(parameter.guid, input);
101104
}

0 commit comments

Comments
 (0)