diff --git a/Source/Editor/Surface/Undo/BoxHandle.cs b/Source/Editor/Surface/Undo/BoxHandle.cs index f50adcfeb..4b77b95f7 100644 --- a/Source/Editor/Surface/Undo/BoxHandle.cs +++ b/Source/Editor/Surface/Undo/BoxHandle.cs @@ -10,7 +10,7 @@ namespace FlaxEditor.Surface.Undo /// The helper structure for Surface node box handle. /// [HideInEditor] - public struct BoxHandle + public struct BoxHandle : IEquatable { private readonly uint _nodeId; private readonly int _boxId; @@ -51,5 +51,27 @@ namespace FlaxEditor.Surface.Undo throw new Exception("Missing box."); return box; } + + /// + public override bool Equals(object obj) + { + return obj is BoxHandle handle && Equals(handle); + } + + /// + public bool Equals(BoxHandle other) + { + return _nodeId == other._nodeId && + _boxId == other._boxId; + } + + /// + public override int GetHashCode() + { + unchecked + { + return (_nodeId.GetHashCode() * 397) ^ _boxId.GetHashCode(); + } + } } } diff --git a/Source/Editor/Surface/Undo/ConnectBoxesAction.cs b/Source/Editor/Surface/Undo/ConnectBoxesAction.cs index 6627364ed..a4e59a8ac 100644 --- a/Source/Editor/Surface/Undo/ConnectBoxesAction.cs +++ b/Source/Editor/Surface/Undo/ConnectBoxesAction.cs @@ -104,9 +104,12 @@ namespace FlaxEditor.Surface.Undo } for (int i = 0; i < output.Length; i++) { - var box = output[i].Get(context); - oB.Connections.Add(box); - box.Connections.Add(oB); + if (!output[i].Equals(_input)) + { + var box = output[i].Get(context); + oB.Connections.Add(box); + box.Connections.Add(oB); + } } toUpdate.AddRange(iB.Connections);