Skip to content

Commit 483fe77

Browse files
committed
Interactivity: fixed special case when a GenericMul. which must be convert to Rotate3d, which has inputs from a CustomEvent,
1 parent b28a83f commit 483fe77

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

Editor/Scripts/Interactivity/VisualScriptingExport/UnitExporters/Math/GenericMultiplyUnitExporter.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ bool IsQuaternionInput(ValueInput input)
7272
mulNode.FirstValueOut().MapToPort(unit.product);
7373

7474
// We need to check later - when its available - the input type of the node,
75-
unitExporter.vsExportContext.OnUnitNodesCreated += nodes =>
75+
unitExporter.vsExportContext.OnUnitNodesCreatedStage2 += nodes =>
7676
{
7777
var valueTypeA = unitExporter.vsExportContext.GetValueTypeForInput(mulNode, "a");
7878
var valueTypeB = unitExporter.vsExportContext.GetValueTypeForInput(mulNode, "b");
@@ -81,8 +81,15 @@ bool IsQuaternionInput(ValueInput input)
8181
&& valueTypeB == GltfTypes.TypeIndexByGltfSignature("float3"))
8282
{
8383
mulNode.SetSchema(new Math_Rotate3dNode(), false);
84-
mulNode.ValueIn("b").SetType(TypeRestriction.LimitToFloat4);
85-
mulNode.ValueIn("a").SetType(TypeRestriction.LimitToFloat3);
84+
var oldSocketA = mulNode.ValueIn("a");
85+
var oldSocketB = mulNode.ValueIn("b");
86+
mulNode.ValueInConnection.Clear();
87+
88+
mulNode.ValueIn(Math_Rotate3dNode.IdInputQuaternion);
89+
mulNode.ValueIn(Math_Rotate3dNode.IdInputVector);
90+
91+
mulNode.ValueInConnection[Math_Rotate3dNode.IdInputQuaternion] = oldSocketA.socket.Value;
92+
mulNode.ValueInConnection[Math_Rotate3dNode.IdInputVector] = oldSocketB.socket.Value;
8693
mulNode.FirstValueOut().ExpectedType(ExpectedType.Float3);
8794
}
8895
else

Editor/Scripts/Interactivity/VisualScriptingExport/VisualScriptingExportContext.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public class ExportGraph
7070

7171
public delegate void OnUnitNodesCreatedDelegate(List<GltfInteractivityExportNode> nodes);
7272
public event OnUnitNodesCreatedDelegate OnUnitNodesCreated;
73+
public event OnUnitNodesCreatedDelegate OnUnitNodesCreatedStage2;
7374

7475
internal Dictionary<InputPortGraph, InputPortGraph> graphBypasses = new Dictionary<InputPortGraph, InputPortGraph>(new InputportGraphComparer());
7576
internal List<ExportGraph> addedGraphs = new List<ExportGraph>();
@@ -418,6 +419,7 @@ internal void AfterSceneExport(GLTFSceneExporter exporter, GLTFRoot gltfRoot, Li
418419
}
419420

420421
OnUnitNodesCreated?.Invoke(nodesToSerialize);
422+
OnUnitNodesCreatedStage2?.Invoke(nodesToSerialize);
421423

422424
RemoveUnconnectedNodes();
423425

0 commit comments

Comments
 (0)