From 0fc507e2383e6248ad037e4ddd8f1c8e2fca84f5 Mon Sep 17 00:00:00 2001 From: Nils Hausfeld Date: Sat, 1 Jun 2024 14:23:36 +0200 Subject: [PATCH] - Visject Drag and Drop now tries to get a parameter setter node while holding the alt key - Visual Script surface now returns a setter node --- .../Editor/Surface/VisjectSurface.DragDrop.cs | 20 ++++++++++++++++++- Source/Editor/Surface/VisualScriptSurface.cs | 8 ++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/Source/Editor/Surface/VisjectSurface.DragDrop.cs b/Source/Editor/Surface/VisjectSurface.DragDrop.cs index 7cbbdc876..639d749c7 100644 --- a/Source/Editor/Surface/VisjectSurface.DragDrop.cs +++ b/Source/Editor/Surface/VisjectSurface.DragDrop.cs @@ -129,7 +129,12 @@ namespace FlaxEditor.Surface /// The drag drop arguments data. protected virtual void HandleDragDropParameters(List objects, DragDropEventArgs args) { - var arch = GetParameterGetterNodeArchetype(out var groupId); + // Try to get the setter node when holding the ALT key, otherwise get the getter node + if (!Input.GetKey(KeyboardKeys.Alt) || !TryGetParameterSetterNodeArchetype(out var groupId, out var arch)) + { + arch = GetParameterGetterNodeArchetype(out groupId); + } + for (int i = 0; i < objects.Count; i++) { var parameter = GetParameter(objects[i]); @@ -156,5 +161,18 @@ namespace FlaxEditor.Surface groupId = 6; return Archetypes.Parameters.Nodes[0]; } + + /// + /// Tries to get the parameter setter node archetype to use. + /// + /// The group ID. + /// The node archetype. + /// True if a setter node exists. + protected virtual bool TryGetParameterSetterNodeArchetype(out ushort groupId, out NodeArchetype archetype) + { + groupId = 0; + archetype = null; + return false; + } } } diff --git a/Source/Editor/Surface/VisualScriptSurface.cs b/Source/Editor/Surface/VisualScriptSurface.cs index 00c34d8d5..ee0a3c6d6 100644 --- a/Source/Editor/Surface/VisualScriptSurface.cs +++ b/Source/Editor/Surface/VisualScriptSurface.cs @@ -187,6 +187,14 @@ namespace FlaxEditor.Surface return Archetypes.Parameters.Nodes[2]; } + /// + protected override bool TryGetParameterSetterNodeArchetype(out ushort groupId, out NodeArchetype archetype) + { + groupId = 6; + archetype = Archetypes.Parameters.Nodes[3]; + return true; + } + /// protected override void OnShowPrimaryMenu(VisjectCM activeCM, Float2 location, Box startBox) {