Skip to content

Commit 0009e53

Browse files
PaulDemeulenaereGitHub Enterprise
authored andcommitted
Fix Event connected directly to Output Event (revival) (#154)
* Add missing filter in CanLink function * Add editor test * *Update changelog.md * *Update comment * *Update Comment * Fix regression with subgraph * Add Subgraph_Event_Link_To_Spawn editor test
1 parent 4a0458e commit 0009e53

File tree

4 files changed

+62
-0
lines changed

4 files changed

+62
-0
lines changed

TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/Editor/Tests/VFXContextTests.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,24 @@ public void MultiLinkSpawnerSpawnerAfterSpawnerInit()
194194
Assert.AreEqual(2, from.outputContexts.Count());
195195
}
196196

197+
198+
[Test] //see fogbugz 1269756
199+
public void Link_Fail_From_Event_To_OutputEvent()
200+
{
201+
var from = ScriptableObject.CreateInstance<VFXBasicEvent>();
202+
var to = ScriptableObject.CreateInstance<VFXOutputEvent>();
203+
Assert.IsFalse(VFXContext.CanLink(from, to));
204+
}
205+
206+
[Test]
207+
public void Link_Fail_From_Event_To_Initialize()
208+
{
209+
//For now, we can't use direct link from event to initialize context.
210+
var from = ScriptableObject.CreateInstance<VFXBasicEvent>();
211+
var to = ScriptableObject.CreateInstance<VFXBasicInitialize>();
212+
Assert.IsFalse(VFXContext.CanLink(from, to));
213+
}
214+
197215
[Test]
198216
public void Link_Fail()
199217
{

TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/Editor/Tests/VFXControllerTests.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,45 @@ public void ConvertToSubgraph()
940940

941941
window.graphView.controller = null;
942942
}
943+
944+
[Test]
945+
public void Subgraph_Event_Link_To_Spawn()
946+
{
947+
VFXViewWindow window = VFXViewWindow.GetWindow<VFXViewWindow>();
948+
window.LoadAsset(AssetDatabase.LoadAssetAtPath<VisualEffectAsset>(testAssetName), null);
949+
950+
//Create Spawner in subgraph
951+
{
952+
var spawner = ScriptableObject.CreateInstance<VFXBasicSpawner>();
953+
m_ViewController.graph.AddChild(spawner);
954+
m_ViewController.LightApplyChanges();
955+
956+
var controller = window.graphView.Query<VFXContextUI>().ToList().Select(t => t.controller).Cast<Controller>();
957+
Assert.AreEqual(1, controller.Count());
958+
VFXConvertSubgraph.ConvertToSubgraphContext(window.graphView, controller, Rect.zero, testSubgraphSubAssetName);
959+
}
960+
961+
var subGraphController = m_ViewController.allChildren.OfType<VFXContextController>().FirstOrDefault(o => o.model is VFXSubgraphContext);
962+
Assert.IsNotNull(subGraphController);
963+
964+
//Create Event Context & Link the two input flow
965+
var subGraphContext = subGraphController.model;
966+
var eventContext = ScriptableObject.CreateInstance<VFXBasicEvent>();
967+
968+
Assert.IsTrue(VFXContext.CanLink(eventContext, subGraphContext, 0, 0));
969+
Assert.IsTrue(VFXContext.CanLink(eventContext, subGraphContext, 0, 1));
970+
971+
eventContext.LinkTo(subGraphContext, 0, 0);
972+
eventContext.LinkTo(subGraphContext, 0, 1);
973+
974+
var flow = eventContext.outputFlowSlot.First().link;
975+
Assert.AreEqual(2, flow.Count());
976+
Assert.IsTrue(flow.All(o => o.context == subGraphContext));
977+
Assert.IsTrue(flow.Any(o => o.slotIndex == 0));
978+
Assert.IsTrue(flow.Any(o => o.slotIndex == 1));
979+
980+
window.graphView.controller = null;
981+
}
943982
}
944983
}
945984
#endif

com.unity.visualeffectgraph/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ The version number for this package has increased due to a version update of a r
5858
- Fixed Set Strip Progress Attribute utility block in Additional Samples
5959
- Fix [Case 1255182](https://fogbugz.unity3d.com/f/cases/1255182/)
6060
- Remove temporarily "Exact Fixed Time Step" option on VisualEffectAsset to avoid unexpected behavior
61+
- Forbid incorrect link between incompatible context [Case 1269756](https://issuetracker.unity3d.com/product/unity/issues/guid/1269756/)
6162

6263
## [10.1.0] - 2020-10-12
6364
### Added

com.unity.visualeffectgraph/Editor/Models/Contexts/VFXContext.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,10 @@ public static bool CanLink(VFXContext from, VFXContext to, int fromIndex = 0, in
245245
if (from.m_ContextType == VFXContextType.SpawnerGPU && to.m_ContextType == VFXContextType.OutputEvent)
246246
return false;
247247

248+
//Can't connect directly event to context (OutputEvent or Initialize) for now
249+
if (from.m_ContextType == VFXContextType.Event && to.contextType != VFXContextType.Spawner && to.contextType != VFXContextType.Subgraph)
250+
return false;
251+
248252
return true;
249253
}
250254

0 commit comments

Comments
 (0)