Fix Visject Node layout when adding boxes from code

This commit is contained in:
Wojtek Figat
2021-01-26 22:52:35 +01:00
parent 59858ecb27
commit 854d0147dd

View File

@@ -314,12 +314,16 @@ namespace FlaxEditor.Surface
{ {
if (type == ScriptType.Null) if (type == ScriptType.Null)
type = new ScriptType(typeof(object)); type = new ScriptType(typeof(object));
// Try to reuse box
var box = GetBox(id); var box = GetBox(id);
if ((isOut && box is InputBox) || (!isOut && box is OutputBox)) if ((isOut && box is InputBox) || (!isOut && box is OutputBox))
{ {
box.Dispose(); box.Dispose();
box = null; box = null;
} }
// Create new if missing
if (box == null) if (box == null)
{ {
if (isOut) if (isOut)
@@ -330,10 +334,15 @@ namespace FlaxEditor.Surface
} }
else else
{ {
// Sync properties for exiting box
box.Text = text; box.Text = text;
box.CurrentType = type; box.CurrentType = type;
box.Y = Constants.NodeMarginY + Constants.NodeHeaderSize + yLevel * Constants.LayoutOffsetY; box.Y = Constants.NodeMarginY + Constants.NodeHeaderSize + yLevel * Constants.LayoutOffsetY;
} }
// Update box
box.OnConnectionsChanged();
return box; return box;
} }