private void OnOutputSocketClicked(SocketOutput output, PointerEventData eventData) { if (eventData.button == PointerEventData.InputButton.Right) { connections.Where(conn => conn.output == output) .ToList() .ForEach(conn => Disconnect(conn)); } }
private void OnOutputDragStarted(SocketOutput socketOnDrag) { _currentDraggingSocket = socketOnDrag; drawer.StartDrag(_currentDraggingSocket); // check socket connection type if (_currentDraggingSocket.HasConnection()) { // if single, disconnect if (_currentDraggingSocket.connectionType == ConnectionType.Single) { Disconnect(_currentDraggingSocket.connection); } } }
public void Connect(SocketInput input, SocketOutput output) { var connection = new Connection() { connId = CreateId, input = input, output = output }; input.Connect(connection); output.Connect(connection); connections.Add(connection); input.parentNode.Connect(input, output); drawer.Add(connection.connId, output.handle, input.handle); }
private void OnOutputDragDroppedTo(SocketInput target) { if (_currentDraggingSocket == null || target == null) { _currentDraggingSocket = null; drawer.CancelDrag(); return; } // if sockets connected already // do nothing if (_currentDraggingSocket.HasConnection() && target.HasConnection()) { if (_currentDraggingSocket.connection == target.connection) { _currentDraggingSocket = null; drawer.CancelDrag(); return; } } if (target != null) { // check if input allows multiple connection if (target.HasConnection()) { // disconnect old connection if (target.connectionType != ConnectionType.Multiple) { Disconnect(target.connection); } } Connect(target, _currentDraggingSocket); } _currentDraggingSocket = null; drawer.CancelDrag(); }
public void Disconnect(SocketInput input, SocketOutput output) { connectedOutputs.Remove(output); OnDisconnectEvent?.Invoke(input, output); }
public void Connect(SocketInput input, SocketOutput output) { connectedOutputs.Add(output); OnConnectionEvent?.Invoke(input, output); }
public void Register(SocketOutput output) { output.Init(this); outputs.Add(output); }
public static void InvokeOutputSocketClick(SocketOutput output, PointerEventData eventData) { OutputSocketClickEvent?.Invoke(output, eventData); }
public static void InvokeSocketDragFrom(SocketOutput output) { OutputSocketDragStartEvent?.Invoke(output); }