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();
        }