Exemplo n.º 1
0
 public override void BuildContextualMenu(ContextualMenuPopulateEvent evt)
 {
     // Disable the context menu for the stack. This prevents a duplicate "disconnect all"
     // option from getting registered which grays out stack block node's option.
 }
Exemplo n.º 2
0
        /// <summary>
        /// Add the New Group entry to the context menu
        /// </summary>
        /// <param name="evt"></param>
        protected virtual void BuildGroupContextualMenu(ContextualMenuPopulateEvent evt)
        {
            Vector2 position = (evt.currentTarget as VisualElement).ChangeCoordinatesTo(contentViewContainer, evt.localMousePosition);

            evt.menu.AppendAction("New Group", (e) => AddSelectionsToGroup(AddGroup(new Group("New Group", position))), DropdownMenuAction.AlwaysEnabled);
        }
Exemplo n.º 3
0
 protected void BuildViewContextualMenu(ContextualMenuPopulateEvent evt)
 {
     evt.menu.AppendAction("View/Processor", (e) => ToggleView <ProcessorView>(), (e) => GetPinnedElementStatus <ProcessorView>());
 }
 void BuildContextualMenu(ContextualMenuPopulateEvent evt)
 {
     evt.menu.AppendAction("Rename", (a) => OpenTextEditor(), DropdownMenu.MenuAction.AlwaysEnabled);
 }
Exemplo n.º 5
0
 void OnContextualMenuEvent(ContextualMenuPopulateEvent evt)
 {
     GraphView.BuildContextualMenu(evt);
 }
Exemplo n.º 6
0
 void BuildContextualMenu(ContextualMenuPopulateEvent evt)
 {
     evt.menu.AppendAction("Reset Reference", e => { ResetReferenceAction(); }, DropdownMenuAction.AlwaysEnabled);
 }
 public override void BuildContextualMenu(ContextualMenuPopulateEvent evt)
 {
 }
Exemplo n.º 8
0
 public override void BuildContextualMenu(ContextualMenuPopulateEvent evt)
 {
     evt.menu.AppendAction("Unpack Output", ToggleUnpackOutput, UnpackOutputStatus);
     base.BuildContextualMenu(evt);
 }
Exemplo n.º 9
0
        public override void BuildContextualMenu(ContextualMenuPopulateEvent evt)
        {
            Vector2 mousePosition = evt.mousePosition;

            base.BuildContextualMenu(evt);
            if (evt.target is GraphView)
            {
                evt.menu.InsertAction(1, "Create Sticky Note", (e) => { AddStickyNote(mousePosition); });

                foreach (AbstractMaterialNode node in graph.GetNodes <AbstractMaterialNode>())
                {
                    if (node.hasPreview && node.previewExpanded == true)
                    {
                        evt.menu.InsertAction(2, "Collapse All Previews", CollapsePreviews, (a) => DropdownMenuAction.Status.Normal);
                    }
                    if (node.hasPreview && node.previewExpanded == false)
                    {
                        evt.menu.InsertAction(2, "Expand All Previews", ExpandPreviews, (a) => DropdownMenuAction.Status.Normal);
                    }
                }
                evt.menu.AppendSeparator();
            }

            if (evt.target is GraphView || evt.target is Node)
            {
                if (evt.target is Node node)
                {
                    if (!selection.Contains(node))
                    {
                        selection.Clear();
                        selection.Add(node);
                    }
                }

                InitializeViewSubMenu(evt);
                InitializePrecisionSubMenu(evt);

                evt.menu.AppendAction("Convert To/Sub-graph", ConvertToSubgraph, ConvertToSubgraphStatus);
                evt.menu.AppendAction("Convert To/Inline Node", ConvertToInlineNode, ConvertToInlineNodeStatus);
                evt.menu.AppendAction("Convert To/Property", ConvertToProperty, ConvertToPropertyStatus);
                evt.menu.AppendSeparator();

                var editorView = GetFirstAncestorOfType <GraphEditorView>();
                if (editorView.colorManager.activeSupportsCustom && selection.OfType <MaterialNodeView>().Any())
                {
                    evt.menu.AppendSeparator();
                    evt.menu.AppendAction("Color/Change...", ChangeCustomNodeColor,
                                          eventBase => DropdownMenuAction.Status.Normal);

                    evt.menu.AppendAction("Color/Reset", menuAction =>
                    {
                        graph.owner.RegisterCompleteObjectUndo("Reset Node Color");
                        foreach (var selectable in selection)
                        {
                            if (selectable is MaterialNodeView nodeView)
                            {
                                nodeView.node.ResetColor(editorView.colorManager.activeProviderName);
                                editorView.colorManager.UpdateNodeView(nodeView);
                            }
                        }
                    }, eventBase => DropdownMenuAction.Status.Normal);
                }

                if (selection.OfType <IShaderNodeView>().Count() == 1)
                {
                    evt.menu.AppendSeparator();
                    evt.menu.AppendAction("Open Documentation _F1", SeeDocumentation, SeeDocumentationStatus);
                }
                if (selection.OfType <IShaderNodeView>().Count() == 1 && selection.OfType <IShaderNodeView>().First().node is SubGraphNode)
                {
                    evt.menu.AppendSeparator();
                    evt.menu.AppendAction("Open Sub Graph", OpenSubGraph, (a) => DropdownMenuAction.Status.Normal);
                }
            }
            evt.menu.AppendSeparator();
            // This needs to work on nodes, groups and properties
            if ((evt.target is Node) || (evt.target is StickyNote))
            {
                evt.menu.AppendAction("Group Selection %g", _ => GroupSelection(), (a) =>
                {
                    List <ISelectable> filteredSelection = new List <ISelectable>();

                    foreach (ISelectable selectedObject in selection)
                    {
                        if (selectedObject is Group)
                        {
                            return(DropdownMenuAction.Status.Disabled);
                        }
                        GraphElement ge = selectedObject as GraphElement;
                        if (ge.userData is IGroupItem)
                        {
                            filteredSelection.Add(ge);
                        }
                    }

                    if (filteredSelection.Count > 0)
                    {
                        return(DropdownMenuAction.Status.Normal);
                    }

                    return(DropdownMenuAction.Status.Disabled);
                });

                evt.menu.AppendAction("Ungroup Selection %u", _ => RemoveFromGroupNode(), (a) =>
                {
                    List <ISelectable> filteredSelection = new List <ISelectable>();

                    foreach (ISelectable selectedObject in selection)
                    {
                        if (selectedObject is Group)
                        {
                            return(DropdownMenuAction.Status.Disabled);
                        }
                        GraphElement ge = selectedObject as GraphElement;
                        if (ge.userData is IGroupItem)
                        {
                            if (ge.GetContainingScope() is Group)
                            {
                                filteredSelection.Add(ge);
                            }
                        }
                    }

                    if (filteredSelection.Count > 0)
                    {
                        return(DropdownMenuAction.Status.Normal);
                    }

                    return(DropdownMenuAction.Status.Disabled);
                });
            }

            if (evt.target is ShaderGroup shaderGroup)
            {
                if (!selection.Contains(shaderGroup))
                {
                    selection.Add(shaderGroup);
                }

                var data  = shaderGroup.userData;
                int count = evt.menu.MenuItems().Count;
                evt.menu.InsertAction(count, "Delete Group and Contents", (e) => RemoveNodesInsideGroup(e, data), DropdownMenuAction.AlwaysEnabled);
            }

            if (evt.target is BlackboardField)
            {
                evt.menu.AppendAction("Delete", (e) => DeleteSelectionImplementation("Delete", AskUser.DontAskUser), (e) => canDeleteSelection ? DropdownMenuAction.Status.Normal : DropdownMenuAction.Status.Disabled);
            }
        }
        public void BuildElementContextualMenu(ContextualMenuPopulateEvent evt, VisualElement target)
        {
            var documentElement = target.GetProperty(BuilderConstants.ElementLinkedDocumentVisualElementVEPropertyName) as VisualElement;

            var isValidTarget = documentElement != null && (documentElement.IsPartOfCurrentDocument() || documentElement.GetStyleComplexSelector() != null);

            if (isValidTarget)
            {
                evt.StopImmediatePropagation();
            }

            evt.menu.AppendAction(
                "Copy",
                a =>
            {
                m_Selection.Select(null, documentElement);
                if (documentElement.IsPartOfCurrentDocument() || documentElement.GetStyleComplexSelector() != null)
                {
                    m_PaneWindow.commandHandler.PerformActionOnSelection(
                        m_PaneWindow.commandHandler.CopyElement,
                        m_PaneWindow.commandHandler.ClearCopyBuffer);
                }
            },
                isValidTarget
                    ? DropdownMenuAction.Status.Normal
                    : DropdownMenuAction.Status.Disabled);

            evt.menu.AppendAction(
                "Paste",
                a =>
            {
                m_Selection.Select(null, documentElement);
                m_PaneWindow.commandHandler.Paste();
            },
                string.IsNullOrEmpty(BuilderEditorUtility.SystemCopyBuffer)
                    ? DropdownMenuAction.Status.Disabled
                    : DropdownMenuAction.Status.Normal);

            evt.menu.AppendSeparator();

            evt.menu.AppendAction(
                "Rename",
                a =>
            {
                m_Selection.Select(null, documentElement);
                var explorerItemElement = documentElement.GetProperty(BuilderConstants.ElementLinkedExplorerItemVEPropertyName) as BuilderExplorerItem;
                if (explorerItemElement == null)
                {
                    return;
                }

                explorerItemElement.ActivateRenameElementMode();
            },
                documentElement != null && documentElement.IsPartOfCurrentDocument()
                    ? DropdownMenuAction.Status.Normal
                    : DropdownMenuAction.Status.Disabled);

            evt.menu.AppendAction(
                "Duplicate",
                a =>
            {
                m_Selection.Select(null, documentElement);
                if (documentElement.IsPartOfCurrentDocument() || documentElement.GetStyleComplexSelector() != null)
                {
                    m_PaneWindow.commandHandler.PerformActionOnSelection(
                        m_PaneWindow.commandHandler.DuplicateElement,
                        m_PaneWindow.commandHandler.ClearCopyBuffer,
                        m_PaneWindow.commandHandler.Paste);
                }
            },
                isValidTarget
                    ? DropdownMenuAction.Status.Normal
                    : DropdownMenuAction.Status.Disabled);

            evt.menu.AppendSeparator();

            evt.menu.AppendAction(
                "Delete",
                a =>
                { m_Selection.Select(null, documentElement);
                  m_PaneWindow.commandHandler.DeleteElement(documentElement);
                  m_PaneWindow.commandHandler.ClearSelectionNotify(); },
                isValidTarget
                    ? DropdownMenuAction.Status.Normal
                    : DropdownMenuAction.Status.Disabled);
        }
 void OnSceneContextMenu(ContextualMenuPopulateEvent evt)
 {
     evt.menu.AppendAction(k_PingSubSceneInHierarchy, OnPingSubSceneInHierarchy);
     evt.menu.AppendAction(k_PingSubSceneInProjectWindow, OnPingSubSceneAsset);
 }
Exemplo n.º 12
0
    /// <summary>
    /// Add the New Stack entry to the context menu
    /// </summary>
    /// <param name="evt"></param>
    protected void BuildStackNodeContextualMenu(ContextualMenuPopulateEvent evt)
    {
        Vector2 position = (evt.currentTarget as VisualElement).ChangeCoordinatesTo(contentViewContainer, evt.localMousePosition);

        evt.menu.AppendAction("New Stack", (e) => AddStackNode(new BaseStackNode(position)), DropdownMenuAction.AlwaysEnabled);
    }
Exemplo n.º 13
0
 public override void BuildContextualMenu(ContextualMenuPopulateEvent evt)
 {
     BuildStackNodeContextualMenu(evt);
     base.BuildContextualMenu(evt);
 }
Exemplo n.º 14
0
 void BuildContextualMenu(ContextualMenuPopulateEvent evt)
 {
     evt.menu.AppendAction("Rename", (a) => OpenTextEditor(), DropdownMenuAction.AlwaysEnabled);
     evt.menu.AppendAction("Delete", (a) => _removeAction(parameter), DropdownMenuAction.AlwaysEnabled);
     evt.StopPropagation();
 }
Exemplo n.º 15
0
 private static void BuildContextualMenu(ContextualMenuPopulateEvent evt)
 {
 }
 private void BuildNameFieldContextualMenu(ContextualMenuPopulateEvent evt)
 {
     BuildNameFieldContextualMenu(evt.menu, evt.target);
 }
Exemplo n.º 17
0
 public void BuildContextualMenu(ContextualMenuPopulateEvent evt)
 {
 }
        public override void BuildContextualMenu(ContextualMenuPopulateEvent evt)
        {
            if (evt.target == this || selection.FindAll(s => s is VisualElement ve && ve.userData is MathNode).Contains(evt.target as ISelectable))
            {
                evt.menu.AppendAction("Group Selection (Placemats)", AddToPlacematAction, a =>
                {
                    List <ISelectable> filteredSelection = new List <ISelectable>();
                    foreach (ISelectable selectedObject in selection)
                    {
                        VisualElement ve = selectedObject as VisualElement;
                        if (ve?.userData is MathNode)
                        {
                            filteredSelection.Add(selectedObject);
                        }
                    }

                    return(filteredSelection.Count > 0 ? DropdownMenuAction.Status.Normal : DropdownMenuAction.Status.Disabled);
                });

                evt.menu.AppendAction("Group Selection", AddToGroupNode, a =>
                {
                    List <ISelectable> filteredSelection = new List <ISelectable>();

                    foreach (ISelectable selectedObject in selection)
                    {
                        VisualElement ve = selectedObject as VisualElement;

                        // Disabled if at least one group is selected or if the selected element is in a stack
                        if (ve.userData is MathGroupNode || ve.parent is StackNode)
                        {
                            return(DropdownMenuAction.Status.Disabled);
                        }
                        else if (ve.userData is MathNode)
                        {
                            filteredSelection.Add(selectedObject);
                        }
                    }

                    if (filteredSelection.Count > 0)
                    {
                        return(DropdownMenuAction.Status.Normal);
                    }
                    else
                    {
                        return(DropdownMenuAction.Status.Disabled);
                    }
                });

                evt.menu.AppendAction("Ungroup Selection", RemoveFromGroupNode, a =>
                {
                    List <ISelectable> filteredSelection = new List <ISelectable>();

                    foreach (ISelectable selectedObject in selection)
                    {
                        VisualElement ve = selectedObject as VisualElement;

                        // Disabled if at least one group is selected
                        if (ve.userData is MathGroupNode)
                        {
                            return(DropdownMenuAction.Status.Disabled);
                        }
                        else if (ve.userData is MathNode)
                        {
                            var selectedNode = selectedObject as Node;

                            if (selectedNode.GetContainingScope() is Group)
                            {
                                filteredSelection.Add(selectedObject);
                            }
                        }
                    }

                    if (filteredSelection.Count > 0)
                    {
                        return(DropdownMenuAction.Status.Normal);
                    }
                    else
                    {
                        return(DropdownMenuAction.Status.Disabled);
                    }
                });

                evt.menu.AppendAction("Scope Selection", AddToScope, (a) =>
                {
                    List <ISelectable> filteredSelection = new List <ISelectable>();

                    foreach (ISelectable selectedObject in selection)
                    {
                        GraphElement graphElement = selectedObject as GraphElement;

                        // Disabled if at least one group is selected
                        if (graphElement.userData is MathNode)
                        {
                            Scope scope = graphElement.GetContainingScope();

                            if (scope != null)
                            {
                                return(DropdownMenuAction.Status.Disabled);
                            }

                            filteredSelection.Add(selectedObject);
                        }
                    }

                    if (filteredSelection.Count > 0)
                    {
                        return(DropdownMenuAction.Status.Normal);
                    }
                    else
                    {
                        return(DropdownMenuAction.Status.Disabled);
                    }
                });

                evt.menu.AppendAction("Unscope Selection", RemoveFromScope, (a) =>
                {
                    List <ISelectable> filteredSelection = new List <ISelectable>();

                    foreach (ISelectable selectedObject in selection)
                    {
                        GraphElement graphElement = selectedObject as GraphElement;

                        if (graphElement.userData is MathNode)
                        {
                            Scope scope = graphElement.GetContainingScope();

                            if (scope != null && !(scope is Group))
                            {
                                filteredSelection.Add(graphElement);
                            }
                        }
                    }

                    if (filteredSelection.Count > 0)
                    {
                        return(DropdownMenuAction.Status.Normal);
                    }
                    else
                    {
                        return(DropdownMenuAction.Status.Disabled);
                    }
                });
                evt.menu.AppendSeparator();
            }

            if (evt.target == this)
            {
                evt.menu.AppendAction("Create Group", CreateGroupNode, DropdownMenuAction.AlwaysEnabled);
                evt.menu.AppendAction("Create Stack", CreateStackNode, DropdownMenuAction.AlwaysEnabled);
                evt.menu.AppendAction("Create Renamable Stack", CreateRenamableStackNode, DropdownMenuAction.AlwaysEnabled);
                evt.menu.AppendAction("Create Placemat", CreatePlacemat, DropdownMenuAction.AlwaysEnabled);
                evt.menu.AppendAction("Create StickyNote", CreateStickyNote, DropdownMenuAction.AlwaysEnabled);
            }

            base.BuildContextualMenu(evt);

            evt.menu.AppendAction("Rename Graph View", a =>
            {
                name = name.First() == 'A' ? "A" + name : "A " + name;
                m_SimpleGraphViewWindow.titleContent.text = name;
            }, DropdownMenuAction.AlwaysEnabled);
        }
 public override void BuildContextualMenu(ContextualMenuPopulateEvent evt)
 {
     evt.menu.AppendAction("View Documentation", action => ViewDocumentation(typeof(Graph)));
     evt.menu.AppendSeparator();
     evt.StopPropagation();
 }
Exemplo n.º 20
0
 private void AddContextMenuOptions(ContextualMenuPopulateEvent contextualMenuPopulateEvent,
                                    Tuple <string, Action>[] contextualMenuOptions) =>
 AddContextMenuOptions(contextualMenuPopulateEvent.menu, contextualMenuOptions);
Exemplo n.º 21
0
 /// <inheritdoc />
 protected override void OnSeparatorContextualMenuEvent(ContextualMenuPopulateEvent evt, int separatorIndex)
 {
     // TODO: write the context menu for stack node
 }
Exemplo n.º 22
0
 protected virtual void OnSeparatorContextualMenuEvent(ContextualMenuPopulateEvent evt, int separatorIndex)
 {
 }
        public override void BuildContextualMenu(ContextualMenuPopulateEvent evt)
        {
            base.BuildContextualMenu(evt);
            if (evt.target is GraphView || evt.target is Node)
            {
                evt.menu.AppendAction("Convert To Sub-graph", ConvertToSubgraph, ConvertToSubgraphStatus);
                evt.menu.AppendAction("Convert To Inline Node", ConvertToInlineNode, ConvertToInlineNodeStatus);
                evt.menu.AppendAction("Convert To Property", ConvertToProperty, ConvertToPropertyStatus);

                evt.menu.AppendAction("Group Selection", _ => GroupSelection(), (a) =>
                {
                    List <ISelectable> filteredSelection = new List <ISelectable>();

                    foreach (ISelectable selectedObject in selection)
                    {
                        if (selectedObject is Group)
                        {
                            return(DropdownMenuAction.Status.Disabled);
                        }
                        VisualElement ve = selectedObject as VisualElement;
                        if (ve.userData is AbstractMaterialNode)
                        {
                            var selectedNode = selectedObject as Node;
                            if (selectedNode.GetContainingScope() is Group)
                            {
                                return(DropdownMenuAction.Status.Disabled);
                            }

                            filteredSelection.Add(selectedObject);
                        }
                    }

                    if (filteredSelection.Count > 0)
                    {
                        return(DropdownMenuAction.Status.Normal);
                    }
                    else
                    {
                        return(DropdownMenuAction.Status.Disabled);
                    }
                });

                evt.menu.AppendAction("Ungroup Selection", RemoveFromGroupNode, (a) =>
                {
                    List <ISelectable> filteredSelection = new List <ISelectable>();

                    foreach (ISelectable selectedObject in selection)
                    {
                        if (selectedObject is Group)
                        {
                            return(DropdownMenuAction.Status.Disabled);
                        }
                        VisualElement ve = selectedObject as VisualElement;
                        if (ve.userData is AbstractMaterialNode)
                        {
                            var selectedNode = selectedObject as Node;
                            if (selectedNode.GetContainingScope() is Group)
                            {
                                filteredSelection.Add(selectedObject);
                            }
                        }
                    }

                    if (filteredSelection.Count > 0)
                    {
                        return(DropdownMenuAction.Status.Normal);
                    }
                    else
                    {
                        return(DropdownMenuAction.Status.Disabled);
                    }
                });

                var editorView = GetFirstAncestorOfType <GraphEditorView>();
                if (editorView.colorManager.activeSupportsCustom && selection.OfType <MaterialNodeView>().Any())
                {
                    evt.menu.AppendSeparator();
                    evt.menu.AppendAction("Color/Change...", ChangeCustomNodeColor,
                                          eventBase => DropdownMenuAction.Status.Normal);

                    evt.menu.AppendAction("Color/Reset", menuAction =>
                    {
                        graph.owner.RegisterCompleteObjectUndo("Reset Node Color");
                        foreach (var selectable in selection)
                        {
                            if (selectable is MaterialNodeView nodeView)
                            {
                                nodeView.node.ResetColor(editorView.colorManager.activeProviderName);
                                editorView.colorManager.UpdateNodeView(nodeView);
                            }
                        }
                    }, eventBase => DropdownMenuAction.Status.Normal);
                }

                if (selection.OfType <IShaderNodeView>().Count() == 1)
                {
                    evt.menu.AppendSeparator();
                    evt.menu.AppendAction("Open Documentation", SeeDocumentation, SeeDocumentationStatus);
                }
                if (selection.OfType <IShaderNodeView>().Count() == 1 && selection.OfType <IShaderNodeView>().First().node is SubGraphNode)
                {
                    evt.menu.AppendSeparator();

                    evt.menu.AppendAction("Open Sub Graph", OpenSubGraph, (a) => DropdownMenuAction.Status.Normal);
                }
            }
            else if (evt.target is BlackboardField)
            {
                evt.menu.AppendAction("Delete", (e) => DeleteSelectionImplementation("Delete", AskUser.DontAskUser), (e) => canDeleteSelection ? DropdownMenuAction.Status.Normal : DropdownMenuAction.Status.Disabled);
            }
            if (evt.target is MaterialGraphView)
            {
                evt.menu.AppendAction("Collapse Previews", CollapsePreviews, (a) => DropdownMenuAction.Status.Normal);
                evt.menu.AppendAction("Expand Previews", ExpandPreviews, (a) => DropdownMenuAction.Status.Normal);
                evt.menu.AppendSeparator();
            }
        }
Exemplo n.º 24
0
 public override void BuildContextualMenu(ContextualMenuPopulateEvent evt)
 {
     evt.menu.AppendAction(OpenScriptMenu, (e) => OpenUniNodeSourceCode());
     evt.menu.AppendAction(PortsInfoMenu, (e) => ShowPortsValues());
     base.BuildContextualMenu(evt);
 }
Exemplo n.º 25
0
 void OnContextualMenu(ContextualMenuPopulateEvent evt)
 {
     // If popping a contextual menu on a GraphElement, add the cut/copy actions.
     BuildContextualMenu(evt);
 }
Exemplo n.º 26
0
        public override void BuildContextualMenu(ContextualMenuPopulateEvent evt)
        {
            base.BuildContextualMenu(evt);
            if (evt.target is GraphView || evt.target is Node)
            {
                evt.menu.AppendAction("Convert To Sub-graph", ConvertToSubgraph, ConvertToSubgraphStatus);
                evt.menu.AppendAction("Convert To Inline Node", ConvertToInlineNode, ConvertToInlineNodeStatus);
                evt.menu.AppendAction("Convert To Property", ConvertToProperty, ConvertToPropertyStatus);

                evt.menu.AppendAction("Group Selection", GroupSelection, (a) =>
                {
                    List<ISelectable> filteredSelection = new List<ISelectable>();

                    foreach (ISelectable selectedObject in selection)
                    {
                        if (selectedObject is Group)
                            return DropdownMenuAction.Status.Disabled;
                        VisualElement ve = selectedObject as VisualElement;
                        if (ve.userData is AbstractMaterialNode)
                        {
                            var selectedNode = selectedObject as Node;
                            if (selectedNode.GetContainingScope() is Group)
                                return DropdownMenuAction.Status.Disabled;

                            filteredSelection.Add(selectedObject);
                        }
                    }

                    if (filteredSelection.Count > 0)
                        return DropdownMenuAction.Status.Normal;
                    else
                        return DropdownMenuAction.Status.Disabled;
                });

                evt.menu.AppendAction("Ungroup Selection", RemoveFromGroupNode, (a) =>
                {
                    List<ISelectable> filteredSelection = new List<ISelectable>();

                    foreach (ISelectable selectedObject in selection)
                    {
                        if (selectedObject is Group)
                            return DropdownMenuAction.Status.Disabled;
                        VisualElement ve = selectedObject as VisualElement;
                        if (ve.userData is AbstractMaterialNode)
                        {
                            var selectedNode = selectedObject as Node;
                            if (selectedNode.GetContainingScope() is Group)
                                filteredSelection.Add(selectedObject);
                        }
                    }

                    if (filteredSelection.Count > 0)
                        return DropdownMenuAction.Status.Normal;
                    else
                        return DropdownMenuAction.Status.Disabled;
                });

                if (selection.OfType<MaterialNodeView>().Count() == 1)
                {
                    evt.menu.AppendSeparator();
                    evt.menu.AppendAction("Open Documentation", SeeDocumentation, SeeDocumentationStatus);
                }
                if (selection.OfType<MaterialNodeView>().Count() == 1 && selection.OfType<MaterialNodeView>().First().node is SubGraphNode)
                {
                    evt.menu.AppendSeparator();

                    evt.menu.AppendAction("Open Sub Graph", OpenSubGraph, (a) => DropdownMenuAction.Status.Normal);
                }
            }
            else if (evt.target is BlackboardField)
            {
                evt.menu.AppendAction("Delete", (e) => DeleteSelectionImplementation("Delete", AskUser.DontAskUser), (e) => canDeleteSelection ? DropdownMenuAction.Status.Normal : DropdownMenuAction.Status.Disabled);
            }
            if (evt.target is MaterialGraphView)
            {
                evt.menu.AppendAction("Collapse Previews", CollapsePreviews, (a) => DropdownMenuAction.Status.Normal);
                evt.menu.AppendAction("Expand Previews", ExpandPreviews, (a) => DropdownMenuAction.Status.Normal);
                evt.menu.AppendSeparator();
            }
        }
Exemplo n.º 27
0
        protected void BuildCommentBlockContextualMenu(ContextualMenuPopulateEvent evt)
        {
            Vector2 position = evt.mousePosition - (Vector2)viewTransform.position;

            evt.menu.AppendAction("Comment Block", (e) => AddSelectionsToCommentBlock(AddCommentBlock(new CommentBlock("New Comment Block", position))), DropdownMenuAction.AlwaysEnabled);
        }
Exemplo n.º 28
0
 public void BuildContextualMenu(ContextualMenuPopulateEvent evt)
 {
     evt.menu.AppendAction("Check All", CheckAll, DropdownMenuAction.AlwaysEnabled);
     evt.menu.AppendAction("Check None", CheckNone, DropdownMenuAction.AlwaysEnabled);
 }
Exemplo n.º 29
0
 protected void BuildSelectAssetContextualMenu(ContextualMenuPopulateEvent evt)
 {
     evt.menu.AppendAction("Select Asset", (e) => EditorGUIUtility.PingObject(graph), DropdownMenuAction.AlwaysEnabled);
 }
Exemplo n.º 30
0
 public virtual void BuildContextualMenu(ContextualMenuPopulateEvent evt)
 {
     evt.menu.AppendAction(anchored ? "Make floating" : "Anchor", ToggleAnchorState, ContextualMenu.MenuAction.AlwaysEnabled);
 }