Skip to content

Commit

Permalink
[ShaderGraph][2022] Compare Properties by ID instead of Ref
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Esmeralda Salamone authored and Evergreen committed Oct 13, 2023
1 parent f572a51 commit f6aac47
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static void ConcretizeNode(AbstractMaterialNode node)

public static void ConcretizeProperties(GraphData graph)
{
var propertyNodes = graph.GetNodes<PropertyNode>().Where(n => !graph.m_Properties.Any(p => p == n.property)).ToArray();
var propertyNodes = graph.GetNodes<PropertyNode>().Where(n => !graph.m_Properties.Any(p => p.value.objectId == n.property.objectId)).ToArray();
foreach (var pNode in propertyNodes)
graph.ReplacePropertyNodeWithConcreteNodeNoValidate(pNode);
}
Expand Down

0 comments on commit f6aac47

Please sign in to comment.