public FunctionNode(NodeMachineModel model, Vector2 position) : base(model) { transform.position = position; transform.size = new Vector2(150, 75); background = "Assets/NodeMachine/Editor/Editor Resources/function-node.png"; int addNameNum = 1; while (model.GetFunction(name) != null) { name = "function (" + addNameNum + ")"; addNameNum++; } }
public NodeMenuItem[] NodeContextMenuItems(Node node, NodeMachineModel model) { FunctionNode funcNode = node as FunctionNode; return(new NodeMenuItem[] { new NodeMenuItem("Edit name", () => { if (!funcNode.editingName) { funcNode.editingName = true; } else { FunctionNode func = model.GetFunction(funcNode.name); if (func != null && func != funcNode) { EditorUtility.DisplayDialog("Function exists!", "A function with that name already exists.", "OK"); return; } funcNode.editingName = false; model.UpdateFunctionCache(); } }, funcNode.editingName, false), new NodeMenuItem("Hide function group", () => { foreach (Node hide in funcNode.GetFunctionGroup()) { hide.visible = false; } }, false, false), new NodeMenuItem("Reveal function group", () => { foreach (Node hide in funcNode.GetFunctionGroup()) { hide.visible = true; } }, false, false), new NodeMenuItem("Remove function group", () => { if (EditorUtility.DisplayDialog("Remove function group", "Are you sure you want to remove all nodes in this function?", "Yes", "No")) { foreach (Node remove in funcNode.GetFunctionGroup()) { model.RemoveNode(remove); } } }, false, false) }); }