Esempio n. 1
0
        private void HandleClick(Vector3 center)
        {
            m_buttonRect = new Rect(center.x - 10, center.y - 35, 20, 50f);

            if ((Event.current.type == EventType.MouseUp && Event.current.button == 0))
            {
                var rightClickPos = Event.current.mousePosition;
                if (m_buttonRect.Contains(rightClickPos))
                {
                    this.Inspector.UpdateInspector(this);
                    ConnectionGUIUtility.ConnectionEventHandler(new ConnectionEvent(ConnectionEvent.EventType.EVENT_CONNECTION_TAPPED, this));
                    Event.current.Use();
                }
            }

            if (Event.current.type == EventType.ContextClick ||
                (Event.current.type == EventType.MouseUp && Event.current.button == 1)
                )
            {
                var rightClickPos = Event.current.mousePosition;

                if (m_buttonRect.Contains(rightClickPos))
                {
                    var menu = new GenericMenu();

                    if (connectionDrawer != null)
                    {
                        connectionDrawer.OnContextMenuGUI(menu, this);
                    }

                    menu.AddItem(
                        new GUIContent("Delete"),
                        false,
                        () =>
                    {
                        Delete();
                    }
                        );
                    menu.ShowAsContext();
                    Event.current.Use();
                }
            }
        }
Esempio n. 2
0
        private void HandleClick(Vector2 startV3, Vector2 endV3, Vector2 startTan, Vector2 endTan)
        {
            var bezierPoses = Handles.MakeBezierPoints(startV3, endV3, startTan, endTan, (int)(Vector3.Distance(startV3, endV3) * 0.1f));

            if ((Event.current.type == EventType.MouseUp && Event.current.button == 0))
            {
                if (ClickedOnBezier(bezierPoses))
                {
                    ConnectionGUIUtility.ConnectionEventHandler(new ConnectionEvent(ConnectionEvent.EventType.EVENT_CONNECTION_TAPPED, this));
                    Event.current.Use();
                }
            }

            else if (Event.current.type == EventType.ContextClick || (Event.current.type == EventType.MouseUp && Event.current.button == 1))
            {
                if (ClickedOnBezier(bezierPoses))
                {
                    var menu = new GenericMenu();

                    if (connectionDrawer != null)
                    {
                        connectionDrawer.OnContextMenuGUI(menu, this);
                    }

                    menu.AddItem(
                        new GUIContent("Delete"),
                        false,
                        () =>
                    {
                        Delete();
                    }
                        );
                    menu.ShowAsContext();
                    Event.current.Use();
                }
            }
        }
Esempio n. 3
0
 public void Delete()
 {
     ConnectionGUIUtility.ConnectionEventHandler(new ConnectionEvent(ConnectionEvent.EventType.EVENT_CONNECTION_DELETED, this));
 }