Exemple #1
0
        public override void AddContextMenuItems(GenericMenu menu)
        {
            // Actions if only one node is selected
            if (Selection.objects.Length == 1 && Selection.activeObject is XNode.Node)
            {
                XNode.Node node = Selection.activeObject as XNode.Node;
                menu.AddItem(new GUIContent("Move To Top"), false, () => NodeEditorWindow.current.MoveNodeToTop(node));
                menu.AddItem(new GUIContent("Rename"), false, NodeEditorWindow.current.RenameSelectedNode);
                // Add Mark option for main model
                menu.AddItem(new GUIContent("Mark as main model"), false, () => ((PCGGraphEditor)NodeEditorWindow.current.graphEditor).MarkModelAsMain(_pcgModelNode));
            }

            // Remove Duplicate
            menu.AddItem(new GUIContent("Remove"), false, NodeEditorWindow.current.RemoveSelectedNodes);

            // Custom sctions if only one node is selected
            if (Selection.objects.Length == 1 && Selection.activeObject is XNode.Node)
            {
                XNode.Node node = Selection.activeObject as XNode.Node;
                NodeEditorWindow.AddCustomContextMenuItems(menu, node);
            }
        }
Exemple #2
0
        // Override ContextMenu
        public override void AddContextMenuItems(GenericMenu menu)
        {
            Vector2 pos = NodeEditorWindow.current.WindowToGridPosition(Event.current.mousePosition);

            // Create menu on previously defined available nodes
            foreach (KeyValuePair <string, Type[]> item in _availableNodes)
            {
                foreach (Type t in item.Value)
                {
                    menu.AddItem(new GUIContent($"{item.Key}/{t.Name}"), false, () => {
                        CreateNode(t, pos);
                    });
                }
            }

            /*menu.AddItem(new GUIContent("Test Node"), false, () => {
             *  CreateNode(typeof(TestNode), pos);
             * });*/

            menu.AddSeparator("");
            menu.AddItem(new GUIContent("Preferences"), false, () => NodeEditorWindow.OpenPreferences());
            NodeEditorWindow.AddCustomContextMenuItems(menu, target);
        }