コード例 #1
0
    public void Draw()
    {
        Handles.BeginGUI();
        Handles.color = Color.black;

        Vector2 startPoint = parentNode.GetConnectionPoint();
        Vector2 endPoint   = childNode.GetConnectionPoint();

        startPoint = editor.nodeView.ViewSpaceToScreenSpace(startPoint);
        endPoint   = editor.nodeView.ViewSpaceToScreenSpace(endPoint);

        // Debug.Log("Line pos: " + startPoint + " " + endPoint);

        Handles.DrawLine(startPoint, endPoint);
        Handles.EndGUI();

        Vector2 middlePoint = new Vector2((startPoint.x + endPoint.x) / 2, (startPoint.y + endPoint.y) / 2);

        rect = new Rect(middlePoint.x - BOX_SIZE / 2, middlePoint.y - BOX_SIZE / 2, BOX_SIZE, BOX_SIZE);

        GUIStyle conNodeStyle = new GUIStyle((GUIStyle)"flow node 2");

        GUI.Box(rect, string.Empty, conNodeStyle);

        if (Event.current.type == EventType.MouseUp && Event.current.button == 0 && (Event.current.modifiers & EventModifiers.Alt) != 0)
        {
            DisconnectLine();
            return;
        }

        if (Event.current.type == EventType.MouseUp && Event.current.button == 0)
        {
            ClickedOnSmallBox();
        }
    }