Exemplo n.º 1
0
        public static bool HandleNodeInput(DragNode node, Event e, GraphCamera camera)
        {
            bool inputProcessed = false;

            var mousePosition      = e.mousePosition;
            var mousePositionWorld = camera.ScreenToWorld(mousePosition);
            int dragButton         = 0;

            // If the pins didn't already handle the input, then let the node handle it
            if (!inputProcessed)
            {
                bool insideRect = node.Bounds.Contains(mousePositionWorld);
                if (e.type == EventType.MouseDown && insideRect && e.button == dragButton)
                {
                    node.IsDragging = true;
                    inputProcessed  = true;
                }
                else if (e.type == EventType.MouseUp && insideRect && e.button == dragButton)
                {
                    node.IsDragging = false;
                }
            }

            if (node.IsDragging && !node.Selected)
            {
                node.IsDragging = false;
            }

            if (node.IsDragging && e.type == EventType.MouseDrag)
            {
                inputProcessed = true;
            }

            return(inputProcessed);
        }
Exemplo n.º 2
0
 public void OnDisable()
 {
     keyboardState = null;
     graphCamera   = null;
     if (selectionBox != null)
     {
         selectionBox.SelectionPerformed -= HandleBoxSelection;
         selectionBox = null;
     }
 }
Exemplo n.º 3
0
        public void OnEnable()
        {
            graphCamera   = new GraphCamera();
            keyboardState = new KeyBoardState();
            selectionBox  = new GraphSelectionBox();
            selectionBox.SelectionPerformed += HandleBoxSelection;

            genericMenu = GetGenericMenu();

            if (stateMachineGraph == null)
            {
                stateMachineGraph           = ScriptableObject.CreateInstance <Graph>();
                stateMachineGraph.hideFlags = HideFlags.HideAndDontSave;
            }
            if (stateMachineGraphGUI == null)
            {
                stateMachineGraphGUI = (GetEditor(stateMachineGraph));
            }
        }