private void ShowNodeContextMenu(ActionGraphEditorNode node)
        {
            GenericMenu menu = new GenericMenu();

            // ToDo: disconnection per row
            // ToDo: special entries
            if (node.connectedTo.Any())
            {
                foreach (var info in node.connectedTo)
                {
                    menu.AddItem
                    (
                        new GUIContent($"Disconnect.../{info.Target.Owner.UniqueName}"),
                        false,
                        () => View.DisconnectNodes(info)
                    );
                }
            }
            else
            {
                menu.AddDisabledItem(new GUIContent("Disconnect..."));
            }

            menu.AddItem(new GUIContent("Delete"), false, () => View.DeleteNode(node));

            menu.ShowAsContext();
        }
        private void ShowNodeContextMenu(ActionGraphEditorNode node)
        {
            GenericMenu menu = new GenericMenu();

            if (node.connectedTo.Any())
            {
                foreach (var info in node.connectedTo)
                {
                    menu.AddItem
                    (
                        new GUIContent($"Disconnect.../{info.Node.UniqueName}"),
                        false,
                        () => View.DisconnectNodes(node, info.Node as ActionGraphEditorNode)
                    );
                }
            }
            else
            {
                menu.AddDisabledItem(new GUIContent("Disconnect..."));
            }

            menu.AddItem(new GUIContent("Delete"), false, () => View.DeleteNode(node));

            menu.ShowAsContext();
        }
        private void DeleteFromAsset(ActionGraphEditorNode node)
        {
            Undo.RecordObject(Asset, $"Removed {node.ActionNode.name}");

            switch (node.ActionNode)
            {
            case ActionGraphNode asAction:
            {
                foreach (ActionGraphNode graphNode in Asset.Nodes)
                {
                    graphNode.Connections.Remove(asAction);
                }

                foreach (var entry in Asset.NamedEventEntries)
                {
                    if (entry.Child == asAction)
                    {
                        entry.Child = null;
                    }
                }

                if (Asset.AnyEntryNode)
                {
                    for (int i = 0; i < Asset.AnyEntryNode.Entries.Count; i++)
                    {
                        var entry = Asset.AnyEntryNode.Entries[i];
                        if (entry.Child == asAction)
                        {
                            entry.Child = null;
                            Asset.AnyEntryNode.Entries[i] = entry;
                        }
                    }
                }

                Asset.Nodes.Remove(asAction);
                break;
            }

            case AnyEntry asAny:
            {
                Asset.AnyEntryNode = null;
                break;
            }

            case EventEntry asEvent:
            {
                Asset.NamedEventEntries.Remove(asEvent);
                break;
            }
            }

            /*foreach (ActionGraph.EntryPoint input in Asset.Inputs)
             * {
             *  input.Nodes.Remove(node.ActionNode);
             * }*/
        }
        /*public void OnNodeDisconnected(ActionGraphEditorNode parent, ActionGraphEditorNode toRemove)
         * {
         *  parent.ActionNode.Connections.Remove(toRemove.ActionNode);
         * }*/

        public void OnInputDisconnected(ActionGraphEditorNode child)
        {
            /*Undo.RecordObject(Asset, "Disconnect from input");
             * for (int i = 0; i < Asset.Inputs.Count; i++)
             * {
             *  int index = Asset.Inputs[i].Nodes.IndexOf(child.ActionNode);
             *  if (index != -1)
             *  {
             *      Asset.Inputs[i].Nodes.RemoveAt(index);
             *  }
             * }*/
        }
Exemplo n.º 5
0
 public void DisconnectNodes(GraphNode node, ActionGraphEditorNode child)
 {
     node.RemoveConnection(child);
     if (node == Begin)
     {
         Presenter.OnInputDisconnected(child);
     }
     else
     {
         Presenter.OnNodeDisconnected(node as ActionGraphEditorNode, child);
     }
 }
        public void OnConnectChildNode(ActionGraphEditorNode parent, ActionGraphEditorNode child)
        {
            if (_duringRecreate)
            {
                return;
            }

            var data = OnConnectNodesQueue.Post();

            data.Parent     = parent.ActionNode;
            data.Child      = child.ActionNode;
            data.InputIndex = -1;
        }
        public void OnConnectInputNode(ActionGraphEditorNode node)
        {
            if (_duringRecreate)
            {
                return;
            }

            var data = OnConnectNodesQueue.Post();

            data.Parent     = null;
            data.Child      = node.ActionNode;
            data.InputIndex = CurrentInputTarget;

            CurrentInputTarget = -1;
        }
        private void DeleteFromAsset(ActionGraphEditorNode node)
        {
            Undo.RecordObject(Asset, $"Removed {node.ActionNode.name}");

            foreach (ActionGraphNode graphNode in Asset.Nodes)
            {
                graphNode.Connections.Remove(node.ActionNode);
            }

            foreach (ActionGraph.EntryPoint input in Asset.Inputs)
            {
                input.Nodes.Remove(node.ActionNode);
            }

            Asset.Nodes.Remove(node.ActionNode);
        }
Exemplo n.º 9
0
        private ActionGraphEditorNode CreateNodeEditor(ActionGraphNodeBase node, ActionGraph graph)
        {
            var editorNodeType = FindNodeEditor(node);

            ActionGraphEditorNode editorNode = null;

            if (editorNodeType != null)
            {
                editorNode = Activator.CreateInstance(editorNodeType, graph, node, Presenter)
                             as ActionGraphEditorNode;
            }
            else
            {
                editorNode = new ActionGraphEditorNode(graph, node, Presenter);
            }

            NodeLookup[node] = editorNode;
            Nodes.AddNode(editorNode);

            return(editorNode);
        }
 public void OnNodeDeleted(ActionGraphEditorNode editorNode)
 {
     DeleteFromAsset(editorNode);
 }
 public void OnNodeRightClick(ActionGraphEditorNode node, Vector2 eventMousePos)
 {
     ShowNodeContextMenu(node);
 }
Exemplo n.º 12
0
 public void OnNodeDisconnected(ActionGraphEditorNode parent, ActionGraphEditorNode toRemove)
 {
     parent.ActionNode.Connections.Remove(toRemove.ActionNode);
 }
Exemplo n.º 13
0
 public void OnNodeConnectorClicked(ActionGraphEditorNode node, Vector2 center)
 {
     View.TryBeginConnection(node, center);
 }
Exemplo n.º 14
0
 public void DeleteNode(ActionGraphEditorNode node)
 {
     Nodes.OnDeleteNode.Post().Node = node;
 }