public void UnLink(AbstractSocket socket) { if (socket == null || !socket.IsConnected()) { return; } if (socket.IsInput()) { InputSocket inputSocket = (InputSocket)socket; if (inputSocket.Edge != null) { UnLink(inputSocket, inputSocket.Edge.Output); } } if (socket.IsOutput()) { OutputSocket outputSocket = (OutputSocket)socket; Edge[] edgeCopy = new Edge[outputSocket.Edges.Count]; outputSocket.Edges.CopyTo(edgeCopy); for (int index = 0; index < edgeCopy.Length; index++) { var edge = edgeCopy[index]; UnLink(edge.Input, outputSocket); } } }
private void HandleSocketDrag(AbstractSocket dragSource) { if (dragSource != null) { if (dragSource.IsInput() && dragSource.IsConnected()) { _dragSourceSocket = ((InputSocket)dragSource).Edge.GetOtherSocket(dragSource); _currentCanvas.Graph.UnLink((InputSocket)dragSource, (OutputSocket)_dragSourceSocket); } if (dragSource.IsOutput()) { _dragSourceSocket = dragSource; } Event.current.Use(); } Repaint(); }
private void DrawSocketTooltip(Node node) { Vector2 m = Event.current.mousePosition; AbstractSocket socket = node.SearchSocketAt(m); if (socket != null) { string text = socket.Type + ""; int lastIndex = text.LastIndexOf("."); if (lastIndex > -1) { text = text.Substring(lastIndex + 1); } float width = GUI.skin.label.CalcSize(new GUIContent(text)).x + 8; float xOffset = -width - 10; if (socket.IsOutput()) { xOffset = 10; } _tmpRect.Set(m.x + xOffset, m.y - 10, width, 20); DrawTooltip(_tmpRect, text); } }