void ContextCallback(object obj) { switch (obj.ToString()) { case "0": NodePopupWindow.InitNodePopup(); break; case "1": NodeUtils.LoadGraph(); break; case "2": NodeUtils.UnloadGraph(); break; case "3": NodeUtils.CreateNode(currentGraph, NodeType.Float, mousePosition); break; case "4": NodeUtils.CreateNode(currentGraph, NodeType.Add, mousePosition); break; case "5": NodeUtils.DeleteNode(deleteNodeId, currentGraph); break; default: break; } }
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(); }
void ContextCallBack(object obj) { switch (obj.ToString()) { case "0": NodePopupWindow.InitNodePopup(); break; case "1": NodeUtilities.LoadGraph(); break; case "2": NodeUtilities.UnloadGraph(); break; case "3": NodeUtilities.CreateNode(currentGraph, NodeType.Dialogue, mousePos); break; case "4": NodeUtilities.CreateNode(currentGraph, NodeType.Question, mousePos); break; case "5": NodeUtilities.CreateNode(currentGraph, NodeType.Condicional, mousePos); break; case "6": NodeUtilities.DeleteNode(currentGraph, overNodeID); break; case "7": NodeUtilities.CreateNode(currentGraph, NodeType.Answer, mousePos); break; case "8": NodeUtilities.DisconnectInput(currentGraph, overNodeID); break; case "9": NodeUtilities.DisconnectOutput(currentGraph, overNodeID); break; case "10": NodeUtilities.CreateNode(currentGraph, NodeType.Delay, mousePos); break; default: break; } }
void ContextCallBack(object obj) { switch (obj.ToString()) { case "0": NodePopupWindow.InitNodePopup(); break; case "1": NodeUtils.LoadGraph(); break; case "2": NodeUtils.UnloadGraph(); break; case "3": NodeUtils.CreateNode(curGraph, NodeType.Input, mousePos); break; case "4": NodeUtils.CreateNode(curGraph, NodeType.Adjust, mousePos); break; case "5": NodeUtils.CreateNode(curGraph, NodeType.Output, mousePos); break; case "6": NodeUtils.DeleteNode(deleteNodeID, curGraph); break; default: break; } }
public override void UpdateView(Rect editorRect, Rect precentageRect, Event e, NodeGraph currentGraph) { base.UpdateView(editorRect, precentageRect, e, currentGraph); GUILayout.BeginHorizontal("box"); if (GUILayout.Button("Create Graph")) { NodePopupWindow.InitNodePopup(); } if (GUILayout.Button("Load Graph")) { NodeUtilities.LoadGraph(); } if (currentGraph != null) { addNode = EditorGUILayout.Popup(addNode, new string[] { "Add Node", "Add Dialogue", "Add Question", "Add Condition", "Add Answer", "Add Delay" }, "Dropdown"); switch (addNode) { case 1: NodeUtilities.CreateNode(currentGraph, NodeType.Dialogue, new Vector2(50, 50)); addNode = 0; break; case 2: NodeUtilities.CreateNode(currentGraph, NodeType.Question, new Vector2(50, 50)); addNode = 0; break; case 3: NodeUtilities.CreateNode(currentGraph, NodeType.Condicional, new Vector2(50, 50)); addNode = 0; break; case 4: NodeUtilities.CreateNode(currentGraph, NodeType.Answer, new Vector2(50, 50)); addNode = 0; break; case 5: NodeUtilities.CreateNode(currentGraph, NodeType.Delay, new Vector2(50, 50)); addNode = 0; break; } if (currentGraph.selectedNode != null) { if (currentGraph.selectedNode.nodeType != NodeType.Start && currentGraph.selectedNode.nodeType != NodeType.End) { editNode = EditorGUILayout.Popup(editNode, new string[] { "Edit Node", "Disconect input", "Disconect output", "Delete node" }, "Dropdown"); } if (currentGraph.selectedNode.nodeType == NodeType.End) { editNode = EditorGUILayout.Popup(editNode, new string[] { "Edit Node", "Disconect input" }, "Dropdown"); } if (currentGraph.selectedNode.nodeType == NodeType.Start) { editNode = EditorGUILayout.Popup(editNode, new string[] { "Edit Node", "Disconect output" }, "Dropdown"); } switch (editNode) { case 1: if (currentGraph.selectedNode.nodeType != NodeType.Start) { NodeUtilities.DisconnectInput(currentGraph, currentGraph.nodes.IndexOf(currentGraph.selectedNode)); } if (currentGraph.selectedNode.nodeType == NodeType.Start) { NodeUtilities.DisconnectOutput(currentGraph, currentGraph.nodes.IndexOf(currentGraph.selectedNode)); } editNode = 0; break; case 2: NodeUtilities.DisconnectOutput(currentGraph, currentGraph.nodes.IndexOf(currentGraph.selectedNode)); editNode = 0; break; case 3: NodeUtilities.DeleteNode(currentGraph, currentGraph.nodes.IndexOf(currentGraph.selectedNode)); editNode = 0; break; } } if (GUILayout.Button("Unload Graph")) { NodeUtilities.UnloadGraph(); } } GUILayout.EndHorizontal(); }