Skip to content

Commit 8bda777

Browse files
PaulDemeulenaereGitHub Enterprise
authored andcommitted
[Subgraph] Prevent Pasting Context invalid subgraph (#191)
* Prevent pasting context within operator/block subgraph * Fix case https://github.cds.internal.unity3d.com/unity/vfx-graphics/pull/191#discussion_r102007 Fix Approximate english log warning * Update VFXPaste log message Missing "the"
1 parent 5d3b2b0 commit 8bda777

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

com.unity.visualeffectgraph/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2222
- Fix [Case 1290493](https://fogbugz.unity3d.com/f/cases/1290493/#BugEvent.1072735759)
2323
- Incorrect path on Linux while targetting Android, IOS or WebGL [Case 1279750](https://issuetracker.unity3d.com/product/unity/issues/guid/1279750/)
2424
- Prevent creation of subgraph containing only partial systems [Case 1284053](https://issuetracker.unity3d.com/product/unity/issues/guid/1284053/)
25+
- Prevent pasting context within operator/block subgraph [Case 1235269](https://issuetracker.unity3d.com/product/unity/issues/guid/1235269/)
2526

2627
## [10.2.0] - 2020-10-19
2728
### Added

com.unity.visualeffectgraph/Editor/GraphView/Views/VFXPaste.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,21 @@ void PasteAll(VFXViewController viewController, Vector2 center, ref Serializable
167167
pasteOffset = (serializableGraph.bounds.width > 0 && serializableGraph.bounds.height > 0) ? center - serializableGraph.bounds.center : Vector2.zero;
168168
MakePasteOffsetUnique(viewController, serializableGraph);
169169

170-
// Paste all nodes
171-
PasteContexts(viewController, ref serializableGraph);
170+
// Can't paste context within subgraph block/operator
171+
if (viewController.model.visualEffectObject is VisualEffectSubgraphOperator || viewController.model.visualEffectObject is VisualEffectSubgraphBlock)
172+
{
173+
if (serializableGraph.contexts != null)
174+
{
175+
var count = serializableGraph.contexts.Count();
176+
if (count != 0)
177+
Debug.LogWarningFormat("{0} context{1} been skipped during the paste operation. Contexts aren't available in this kind of subgraph.", count, count > 1 ? "s have" : " has");
178+
}
179+
}
180+
else
181+
{
182+
PasteContexts(viewController, ref serializableGraph);
183+
}
184+
172185
PasteOperators(viewController, ref serializableGraph);
173186
PasteParameters(viewController, ref serializableGraph);
174187

@@ -626,7 +639,7 @@ private void RegisterContexts(VFXViewController viewController)
626639
var block = newContexts[i].Value[j];
627640
if (block != null)
628641
{
629-
VFXBlockController blockController = controller.blockControllers.First(t => t.model == block);
642+
VFXBlockController blockController = controller.blockControllers.FirstOrDefault(t => t.model == block);
630643
if (blockController != null)
631644
newControllers[GetBlockID((uint)i, (uint)j)] = blockController;
632645
}

0 commit comments

Comments
 (0)