Fix Visject Node layout when adding boxes from code
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user