properly handle connecting to a box that already has a connection
This commit is contained in:
@@ -544,15 +544,13 @@ namespace FlaxEditor.Surface.Elements
|
|||||||
public override void OnMouseLeave()
|
public override void OnMouseLeave()
|
||||||
{
|
{
|
||||||
if (_originalTooltipText != null)
|
if (_originalTooltipText != null)
|
||||||
{
|
|
||||||
TooltipText = _originalTooltipText;
|
TooltipText = _originalTooltipText;
|
||||||
}
|
|
||||||
if (_isMouseDown)
|
if (_isMouseDown)
|
||||||
{
|
{
|
||||||
_isMouseDown = false;
|
_isMouseDown = false;
|
||||||
if (Surface.CanEdit)
|
if (Surface.CanEdit)
|
||||||
{
|
{
|
||||||
if (Input.GetKey(KeyboardKeys.Control))
|
if (IsOutput && Input.GetKey(KeyboardKeys.Control))
|
||||||
{
|
{
|
||||||
List<Box> connectedBoxes = new List<Box>(Connections);
|
List<Box> connectedBoxes = new List<Box>(Connections);
|
||||||
|
|
||||||
@@ -564,25 +562,21 @@ namespace FlaxEditor.Surface.Elements
|
|||||||
}
|
}
|
||||||
else if (!IsOutput && HasSingleConnection)
|
else if (!IsOutput && HasSingleConnection)
|
||||||
{
|
{
|
||||||
var connectedBox = Connections[0];
|
var otherBox = Connections[0];
|
||||||
if (Surface.Undo != null && Surface.Undo.Enabled)
|
if (Surface.Undo != null && Surface.Undo.Enabled)
|
||||||
{
|
{
|
||||||
var action = new ConnectBoxesAction((InputBox)this, (OutputBox)connectedBox, false);
|
var action = new ConnectBoxesAction((InputBox)this, (OutputBox)otherBox, false);
|
||||||
BreakConnection(connectedBox);
|
BreakConnection(otherBox);
|
||||||
action.End();
|
action.End();
|
||||||
Surface.AddBatchedUndoAction(action);
|
Surface.AddBatchedUndoAction(action);
|
||||||
Surface.MarkAsEdited();
|
Surface.MarkAsEdited();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
BreakConnection(otherBox);
|
||||||
BreakConnection(connectedBox);
|
Surface.ConnectingStart(otherBox);
|
||||||
}
|
|
||||||
Surface.ConnectingStart(connectedBox);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
Surface.ConnectingStart(this);
|
Surface.ConnectingStart(this);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
base.OnMouseLeave();
|
base.OnMouseLeave();
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using FlaxEditor.Scripting;
|
using FlaxEditor.Scripting;
|
||||||
|
using FlaxEditor.Surface.Elements;
|
||||||
using FlaxEngine;
|
using FlaxEngine;
|
||||||
|
|
||||||
namespace FlaxEditor.Surface
|
namespace FlaxEditor.Surface
|
||||||
@@ -269,11 +270,15 @@ namespace FlaxEditor.Surface
|
|||||||
List<IConnectionInstigator> instigators = new List<IConnectionInstigator>(_connectionInstigators);
|
List<IConnectionInstigator> instigators = new List<IConnectionInstigator>(_connectionInstigators);
|
||||||
for (int i = 0; i < instigators.Count; i++)
|
for (int i = 0; i < instigators.Count; i++)
|
||||||
{
|
{
|
||||||
var start = _connectionInstigators[i];
|
var start = instigators[i];
|
||||||
|
|
||||||
// Check if boxes are different and end box is specified
|
// Check if boxes are different and end box is specified
|
||||||
if (start == end || end == null)
|
if (start == end || end == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Properly handle connecting to a socket that already has a connection
|
||||||
|
if (end is Box e && !e.IsOutput && start is Box s && e.AreConnected(s))
|
||||||
|
e.BreakConnection(s);
|
||||||
|
|
||||||
// Connect them
|
// Connect them
|
||||||
if (start.CanConnectWith(end))
|
if (start.CanConnectWith(end))
|
||||||
|
|||||||
Reference in New Issue
Block a user