Example #1
0
        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);
                }
            }
        }
Example #2
0
 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();
 }
Example #3
0
        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);
            }
        }