void HandleDraggConnections(List <Node> nodes, Connection lastDraggedConnection) { switch (Event.current.GetTypeForControl(ControlID)) { case EventType.MouseDown: { StartDraggJoint = GetJointUnderMousePosition(nodes); if (StartDraggJoint != null) { GUIUtility.hotControl = StartDraggJoint.ControlID; Event.current.Use(); } break; } case EventType.mouseUp: { if (StartDraggJoint != null) { Joint EndDragJoint = GetJointUnderMousePosition(nodes); ObjectConnector.TryToMakeNewConnection(StartDraggJoint, EndDragJoint, lastDraggedConnection); StartDraggJoint = null; GUIUtility.hotControl = 0; Event.current.Use(); } break; } } }
public static void TryToMakeNewConnection(Joint from, Joint to, Connection lastDraggedConnection) { if (from != null && to != null) { if (lastDraggedConnection.InputJoint != null && lastDraggedConnection.OutputJoint != null) { ObjectConnector.UpdateExistingConnection(from, to, lastDraggedConnection); } else { ObjectConnector.CreateNewConnection(from, to); } } }