Skip to content

Commit 55affdf

Browse files
authored
Fixed a ShaderGraph issue where the right click menu doesn't work when a stack block node is selected. Fixes fogbugz 1320212. (#4288)
1 parent 94639f7 commit 55affdf

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

com.unity.shadergraph/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
5555
- Fixed an issue where users can't create multiple Boolean or Enum keywords on the blackboard. [1329021](https://issuetracker.unity3d.com/issues/shadergraph-cant-create-multiple-boolean-or-enum-keywords)
5656
- Fixed an issue where generated property reference names could conflict with Shader Graph reserved keywords [1328762] (https://issuetracker.unity3d.com/product/unity/issues/guid/1328762/)
5757
- Fixed a ShaderGraph issue where ObjectField focus and Node selections would both capture deletion commands [1313943].
58+
- Fixed a ShaderGraph issue where the right click menu doesn't work when a stack block node is selected [1320212].
5859

5960
- Fixed a bug when a node was both vertex and fragment exclusive but could still be used causing a shader compiler error [1316128].
6061

com.unity.shadergraph/Editor/Drawing/Views/MaterialGraphView.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,20 @@ public override List<Port> GetCompatiblePorts(Port startAnchor, NodeAdapter node
197197

198198
internal bool ResetSelectedBlockNodes()
199199
{
200+
bool anyNodesWereReset = false;
200201
var selectedBlocknodes = selection.FindAll(e => e is MaterialNodeView && ((MaterialNodeView)e).node is BlockNode).Cast<MaterialNodeView>().ToArray();
201202
foreach (var mNode in selectedBlocknodes)
202203
{
203204
var bNode = mNode.node as BlockNode;
204205
var context = GetContext(bNode.contextData);
205206

207+
// Check if the node is currently floating (it's parent isn't the context view that owns it).
208+
// If the node's not floating then the block doesn't need to be reset.
209+
bool isFloating = mNode.parent != context;
210+
if (!isFloating)
211+
continue;
212+
213+
anyNodesWereReset = true;
206214
RemoveElement(mNode);
207215
context.InsertBlock(mNode);
208216

@@ -212,7 +220,7 @@ internal bool ResetSelectedBlockNodes()
212220
}
213221
if (selectedBlocknodes.Length > 0)
214222
graph.ValidateCustomBlockLimit();
215-
return selectedBlocknodes.Length > 0;
223+
return anyNodesWereReset;
216224
}
217225

218226
public override void BuildContextualMenu(ContextualMenuPopulateEvent evt)

0 commit comments

Comments
 (0)