public DialogNode CreateDialogNode(string nodeName) { var node = new DialogNode { title = nodeName, dialogText = nodeName, guid = Guid.NewGuid().ToString() }; var inputPort = GeneratePort(node, Direction.Input, Port.Capacity.Multi); inputPort.portName = "Input"; node.inputContainer.Add(inputPort); node.styleSheets.Add(Resources.Load <StyleSheet>("Node")); var button = new Button(() => { AddChoicePort(node); }); button.text = "Add Choice"; node.titleContainer.Add(button); var textField = new TextField(string.Empty); textField.RegisterValueChangedCallback(evt => { node.dialogText = evt.newValue; node.title = evt.newValue; }); textField.SetValueWithoutNotify(node.title); node.mainContainer.Add(textField); node.RefreshExpandedState(); node.RefreshPorts(); node.SetPosition(new Rect(Vector2.zero, defaultNodeSize)); return(node); }
DialogNode GenerateEntryPointNode() { var node = new DialogNode { title = "Start", guid = Guid.NewGuid().ToString(), dialogText = "", entryPoint = true }; var outputPort = GeneratePort(node, Direction.Output); outputPort.portName = "Next"; node.outputContainer.Add(outputPort); //node.capabilities &= ~Capabilities.Movable; node.capabilities &= ~Capabilities.Deletable; node.RefreshExpandedState(); node.RefreshPorts(); node.SetPosition(new Rect(100, 200, 100, 150)); return(node); }