private void DrawHeldConnection()
        {
            if (!IsDraggingPort)
            {
                return;
            }

            Color   color = NodePreferences.CONNECTION_PORT_COLOR;
            Vector2 start, end;

            color.a *= 0.6f;

            Vector2 portPosition  = NodeEditor.FindPortRect(DraggedPort).center;// + node.Position;
            Vector2 mousePosition = _mousePosition;

            //mousePosition = WindowToGridPosition(mousePosition);
            //portPosition = GridToWindowPosition(portPosition);
            mousePosition = WindowToWindowPositionNotClipped(mousePosition);
            portPosition  = GridToWindowPositionNotClipped(portPosition);

            if (DraggedPort is InputPort)
            {
                start = mousePosition;
                end   = portPosition;
            }
            else
            {
                start = portPosition;
                end   = mousePosition;
            }

            NodeRendering.DrawConnection(start, end, color, NodePreferences.CONNECTION_WIDTH / Zoom);
        }
        private void DrawConnections()
        {
            //return;
            for (int i = 0; i < Graph.ConnectionCount; i++)
            {
                Connection connection = Graph.GetConnection(i);

                if (connection == null || connection.End == null || connection.Start == null ||
                    connection.End.Node == null || connection.Start.Node == null)
                {
                    Debug.LogWarning("F****d up connection. Removing.");
                    Graph.RemoveConnection(connection);
                    continue;
                }

                Vector2 end         = NodeEditor.FindPortRect(connection.End).center;   // + node.Position;
                Vector2 windowEnd   = GridToWindowPositionNotClipped(end);
                Vector2 start       = NodeEditor.FindPortRect(connection.Start).center; // + output.Node.Position;
                Vector2 windowStart = GridToWindowPositionNotClipped(start);

                if (Selection.Contains(connection))
                {
                    NodeRendering.DrawConnection(windowStart, windowEnd, Color.green,
                                                 NodePreferences.CONNECTION_WIDTH / Zoom * 2, false);
                }

                NodeRendering.DrawConnection(windowStart, windowEnd,
                                             NodePreferences.CONNECTION_PORT_COLOR, NodePreferences.CONNECTION_WIDTH / Zoom);
                DrawConnectionModifiers((start + end) / 2, connection);
            }

            //for (int i = 0; i < _graph.NodeCount; i++)
            //{
            //    Node node = _graph.GetNode(i);
            //    IInput inputNode = node as IInput;
            //    InputPort input = inputNode != null ? inputNode.InputPort : null;
            //    if (input == null) continue;

            //    Vector2 end = NodeEditor.FindPortRect(input).center;// + node.Position;
            //    Vector2 windowEnd = GridToWindowPositionNotClipped(end);
            //    for (int j = 0; j < input.ConnectionsCount; j++)
            //    {
            //        Connection connection = input.GetConnection(j);
            //        if (connection == null)
            //        {
            //            OnNull(input);
            //            continue;
            //        }

            //        Vector2 start = NodeEditor.FindPortRect(connection.Start).center;// + output.Node.Position;
            //        Vector2 windowStart = GridToWindowPositionNotClipped(start);

            //        NodeRendering.DrawConnection(windowStart, windowEnd,
            //            NodePreferences.CONNECTION_PORT_COLOR, NodePreferences.CONNECTION_WIDTH / Zoom);
            //        DrawConnectionModifiers((start + end) / 2, connection);
            //    }
            //}
        }
示例#3
0
 protected void DrawAndCachePort(Port port, Rect rect)
 {
     NodeRendering.DrawPort(rect,
                            NodeResources.OuterDotTexture, NodeResources.DotTexture,
                            Color.white, Color.white, !port.IsConnected);
     if (Event.current.type == EventType.Repaint)
     {
         portRects[port] = rect;
     }
 }
 private void DrawGrid()
 {
     NodeRendering.DrawGrid(position, Zoom, PanOffset);
 }