コード例 #1
0
        private void ProcessEvents(UnityEngine.Event e)
        {
            drag = Vector2.zero;

            switch (e.type)
            {
            case EventType.MouseDown:
                if (e.button == 0)
                {
                    activeDrag = true;

                    if (ConnectPoint <T> .StartPoint != null)
                    {
                        ShowCreateNodeMenu(e.mousePosition, "", (node) =>
                        {
                            if (ConnectPoint <T> .StartPoint.point == Point.In)
                            {
                                node.AddNextNode(ConnectPoint <T> .StartPoint.node);
                            }
                            else
                            {
                                ConnectPoint <T> .StartPoint.node.AddNextNode(node);
                            }

                            ConnectPoint <T> .ClearLine();
                        });
                    }
                }

                if (e.button == 1)
                {
                    ConnectPoint <T> .ClearLine();

                    ShowCreateNodeMenu(e.mousePosition, "Add Node");
                }

                if (e.button == 2)
                {
                    ConnectPoint <T> .ClearLine();
                }
                break;

            case EventType.MouseUp:
                if (e.button == 0)
                {
                    activeDrag = false;
                }
                break;

            case EventType.MouseDrag:
                if (e.button == 0 && activeDrag)
                {
                    OnCanvasDrag(e.delta);
                }
                break;
            }
        }