From f6aac476b37b1317fffed55b0de74db474cc220a Mon Sep 17 00:00:00 2001 From: Esmeralda Salamone Date: Fri, 13 Oct 2023 23:26:58 +0000 Subject: [PATCH] [ShaderGraph][2022] Compare Properties by ID instead of Ref Fix for this issue: https://jira.unity3d.com/browse/UUM-52909. Due to some perf improvements and caching, a previous comparison by reference was no longer valid in undo/redo (which undergoes serialization). This quick fix compares properties by ID instead of reference. --- .../Editor/Data/Actions/GraphViewActions.cs | 12 +++--------- .../Editor/Data/Graphs/GraphConcretization.cs | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/Packages/com.unity.shadergraph/Editor/Data/Actions/GraphViewActions.cs b/Packages/com.unity.shadergraph/Editor/Data/Actions/GraphViewActions.cs index f107e887c6e..56e4187977d 100644 --- a/Packages/com.unity.shadergraph/Editor/Data/Actions/GraphViewActions.cs +++ b/Packages/com.unity.shadergraph/Editor/Data/Actions/GraphViewActions.cs @@ -108,10 +108,8 @@ void DragGraphInput(GraphData graphData) var drawState = node.drawState; drawState.position = new Rect(nodePosition, drawState.position.size); node.drawState = drawState; - graphData.AddNode(node); - - // Setting the guid requires the graph to be set first. node.property = property; + graphData.AddNode(node); break; } case ShaderKeyword keyword: @@ -129,10 +127,8 @@ void DragGraphInput(GraphData graphData) var drawState = node.drawState; drawState.position = new Rect(nodePosition, drawState.position.size); node.drawState = drawState; - graphData.AddNode(node); - - // Setting the guid requires the graph to be set first. node.keyword = keyword; + graphData.AddNode(node); break; } case ShaderDropdown dropdown: @@ -152,10 +148,8 @@ void DragGraphInput(GraphData graphData) var drawState = node.drawState; drawState.position = new Rect(nodePosition, drawState.position.size); node.drawState = drawState; - graphData.AddNode(node); - - // Setting the guid requires the graph to be set first. node.dropdown = dropdown; + graphData.AddNode(node); } break; } diff --git a/Packages/com.unity.shadergraph/Editor/Data/Graphs/GraphConcretization.cs b/Packages/com.unity.shadergraph/Editor/Data/Graphs/GraphConcretization.cs index 8cc862c10bc..b083a67727c 100644 --- a/Packages/com.unity.shadergraph/Editor/Data/Graphs/GraphConcretization.cs +++ b/Packages/com.unity.shadergraph/Editor/Data/Graphs/GraphConcretization.cs @@ -14,7 +14,7 @@ public static void ConcretizeNode(AbstractMaterialNode node) public static void ConcretizeProperties(GraphData graph) { - var propertyNodes = graph.GetNodes().Where(n => !graph.m_Properties.Any(p => p == n.property)).ToArray(); + var propertyNodes = graph.GetNodes().Where(n => !graph.m_Properties.Any(p => p.value.objectId == n.property.objectId)).ToArray(); foreach (var pNode in propertyNodes) graph.ReplacePropertyNodeWithConcreteNodeNoValidate(pNode); }