Example #1
0
        void GraphContextMenu(AbstractView view, Event e)
        {
            AbstractNode curNode = curGraph?.GetNode(e.mousePosition);

            if (curNode != null)
            {
                return;
            }

            GenericMenu menu = new GenericMenu();

            menu.AddItem(new GUIContent("Create Graph"), false, delegate() {
                NodePopupWindow.InitNodePopup(delegate(NodeGraph graph) { OnGraphChange?.Invoke(graph); });
            });
            menu.AddItem(new GUIContent("Load Graph"), false, delegate() { OnGraphChange?.Invoke(NodeUtils.LoadGraph()); });

            if (curGraph != null)
            {
                menu.AddSeparator("");
                menu.AddItem(new GUIContent("Unload Graph"), false, delegate() { OnGraphChange?.Invoke(null); });
                menu.AddSeparator("");
                NodeUtils.GetEnumerableOfType <AbstractNode>().ForEach(delegate(Type t) {
                    menu.AddItem(new GUIContent(t.Name), false, delegate() { NodeUtils.CreateNode(curGraph, t, e.mousePosition); });
                });
            }

            menu.ShowAsContext();
            e.Use();
        }
Example #2
0
        void SelectSingleNode(AbstractView view, Event e)
        {
            // already selecting
            if (isSelecting)
            {
                return;
            }

            // clear node selection unless shift is pressed
            if (!e.shift)
            {
                curGraph.ClearNodeSelection();
            }

            // clicking on node?
            AbstractNode node = curGraph?.GetNode(e.mousePosition);

            if (node == null || node.Contains(e.mousePosition) != NodeEdge.Node)
            {
                return;
            }

            // select node
            node.isSelected = true;
        }
Example #3
0
        void DrawSelectionRectangle(AbstractView source, Event e)
        {
            if (!isSelecting)
            {
                return;
            }

            selection.size += e.delta;
        }
Example #4
0
        void DragNode(AbstractView view, Event e)
        {
            if (curGraph?.GetNode(e.mousePosition) == null)
            {
                return;
            }

            curGraph?.DragNodes(e.delta);
        }
Example #5
0
        void DeleteNode(AbstractView source, Event e)
        {
            if (e.keyCode != KeyCode.Delete)
            {
                return;
            }

            NodeUtils.DeleteNodes(curGraph?.GetNodeSelection());
        }
Example #6
0
        void StartSelectionRectangle(AbstractView source, Event e)
        {
            if (curGraph?.GetNode(e.mousePosition) != null)
            {
                return;
            }

            isSelecting = true;
            selection   = new Rect(e.mousePosition, Vector2.zero);
        }
Example #7
0
        void EndNodeConnection(AbstractView source, Event e)
        {
            if (!isConnecting)
            {
                return;
            }
            isConnecting = false;

            // hovering over node output?
            AbstractNode node = curGraph?.GetNode(e.mousePosition);

            connectionSource.Target = node?.GetInput(e.mousePosition);
        }
Example #8
0
        void EndSelectionRectangle(AbstractView source, Event e)
        {
            if (!isSelecting)
            {
                return;
            }

            isSelecting = false;

            List <AbstractNode> nodes = curGraph?.GetNodes(selection);

            if (!e.shift)
            {
                curGraph.ClearNodeSelection();
            }

            nodes?.ForEach(delegate(AbstractNode node) { node.isSelected = !node.isSelected; });
        }
Example #9
0
        void NodeContextMenu(AbstractView view, Event e)
        {
            AbstractNode curNode = curGraph?.GetNode(e.mousePosition);

            if (curNode == null)
            {
                return;
            }

            GenericMenu menu = new GenericMenu();

            menu.AddItem(new GUIContent("Delete"), false, delegate() {
                NodeUtils.DeleteNode(curNode);
            });

            menu.ShowAsContext();
            e.Use();
        }
Example #10
0
        void StartNodeConnection(AbstractView source, Event e)
        {
            if (isSelecting)
            {
                return;
            }

            // clicking on node input?
            AbstractNode node = curGraph?.GetNode(e.mousePosition);

            connectionSource = node?.GetOutput(e.mousePosition);
            if (connectionSource == null)
            {
                return;
            }

            isConnecting = true;
        }