From 4bacceb19f5e873d4fb3420ef619cfca64793851 Mon Sep 17 00:00:00 2001 From: Zode Date: Mon, 9 Jun 2025 22:49:30 +0300 Subject: [PATCH] Make comparisons automatically expand if needed so it contains the inputs --- .../Editor/Surface/Archetypes/Comparisons.cs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Source/Editor/Surface/Archetypes/Comparisons.cs b/Source/Editor/Surface/Archetypes/Comparisons.cs index bcf0159d2..22adea949 100644 --- a/Source/Editor/Surface/Archetypes/Comparisons.cs +++ b/Source/Editor/Surface/Archetypes/Comparisons.cs @@ -20,6 +20,7 @@ namespace FlaxEditor.Surface.Archetypes { TypeID = id, Title = title, + Create = (id, context, arch, groupArch) => new ComparisonNode(id, context, arch, groupArch), Description = desc, Flags = NodeFlags.AllGraphs, AlternativeTitles = altTitles, @@ -44,6 +45,28 @@ namespace FlaxEditor.Surface.Archetypes }; } + private class ComparisonNode : SurfaceNode + { + public ComparisonNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch) + : base(id, context, nodeArch, groupArch) + { + } + + public override void OnSurfaceLoaded(SurfaceNodeActions action) + { + base.OnSurfaceLoaded(action); + + ResizeAuto(); + } + + public override void ConnectionTick(Box box) + { + base.ConnectionTick(box); + + ResizeAuto(); + } + } + private class SwitchOnEnumNode : SurfaceNode { public SwitchOnEnumNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch) @@ -181,6 +204,7 @@ namespace FlaxEditor.Surface.Archetypes { TypeID = 7, Title = "Switch On Bool", + Create = (id, context, arch, groupArch) => new ComparisonNode(id, context, arch, groupArch), AlternativeTitles = new[] { "if", "switch" }, Description = "Returns one of the input values based on the condition value", Flags = NodeFlags.AllGraphs,