public static void AddChoicePort(ChoiceNode node, string questionValue, string next = "") { var port = DialoguePort.Create(Direction.Output, Port.Capacity.Single); int questIndex = node.choiceCount; port.portName = $"Choice {node.choiceCount}"; var lineText = new TextField { name = string.Empty, multiline = true }; lineText.value = questionValue; (port as DialoguePort).Question = questionValue; lineText.RegisterValueChangedCallback(e => { (port as DialoguePort).Question = e.newValue; }); (port as DialoguePort).Next = next; node.choiceCount++; node.outputContainer.Add(port); node.outputContainer.Add(lineText); node.RefreshPorts(); node.RefreshExpandedState(); }
public static Port Create(Direction direction, Capacity capacity) { var connector = new EdgeConnectorListener(); var port = new DialoguePort(Orientation.Horizontal, direction, capacity, null) { m_EdgeConnector = new EdgeConnector <Edge>(connector) }; port.AddManipulator(port.m_EdgeConnector); return(port); }
public static StartNode Create() { var node = new StartNode() { title = "Entry Point", Guid = System.Guid.NewGuid().ToString(), isEntryPoint = true, name = "CustomNode" }; var port = DialoguePort.Create(Direction.Output, Port.Capacity.Single); port.portName = "Next"; node.capabilities &= ~Capabilities.Movable; node.capabilities &= ~Capabilities.Deletable; node.outputContainer.Add(port); node.SetPosition(new Rect(100, 100, 0, 0)); node.RefreshPorts(); node.RefreshExpandedState(); return(node); }
public static ChoiceNode Create(string title) { var node = new ChoiceNode { title = title, Guid = System.Guid.NewGuid().ToString(), isChoiceNode = true, name = "CustomNode", }; var inputPort = DialoguePort.Create(Direction.Input, Port.Capacity.Multi); inputPort.portName = "Prev"; node.inputContainer.Add(inputPort); var choiceButton = new Button(() => { AddChoicePort(node, string.Empty); }); choiceButton.text = "Add Branch"; node.titleButtonContainer.Add(choiceButton); ///Begin Log Button, if its Delete Later var LogButton = new Button(() => { //node.Questions.ForEach(e => Debug.Log($"<color=red>{e}</color>")); }) { text = "Log Data" }; node.titleButtonContainer.Add(LogButton); ///End Log Button return(node); }
private Port CreatePort(Direction direction, Port.Capacity capacity = Port.Capacity.Single) { var port = DialoguePort.Create(direction, capacity); return(port); }
public static DialogueNode Create(string title, DialogueProperties properties, string next = "") { var node = new DialogueNode { title = title, Guid = System.Guid.NewGuid().ToString(), name = "CustomNode", Properties = properties, }; var inputPort = DialoguePort.Create(Direction.Input, Port.Capacity.Multi); inputPort.portName = "Prev"; inputPort.name = "Port"; var outputPort = DialoguePort.Create(Direction.Output, Port.Capacity.Single); outputPort.portName = "Next"; outputPort.name = "Port"; (outputPort as DialoguePort).Next = next; var propertiesFoldout = new Foldout { text = "Dialogue Properties" }; //Dialogue Background var bgField = new ObjectField { objectType = typeof(Sprite), value = properties.Speaker, label = "Background" }; bgField.RegisterValueChangedCallback(e => { node.Properties.Background = e.newValue as Sprite; }); node.Properties.Background = bgField.value as Sprite; //Create Dialogue Properties var sentenceTextfield = new TextField { value = properties.Text, multiline = true, }; node.Properties.Text = sentenceTextfield.value; sentenceTextfield.RegisterValueChangedCallback(e => { node.Properties.Text = e.newValue; }); //Create Speaker var speakerField = new ObjectField { objectType = typeof(Character), value = properties.Speaker, label = "Speaker" }; speakerField.RegisterValueChangedCallback(e => { node.Properties.Speaker = e.newValue as Character; }); node.Properties.Speaker = speakerField.value as Character; var speakerPositionEnum = new EnumField(); speakerPositionEnum.label = "Speaker On-Screen Position"; speakerPositionEnum.Init(CharacterScreenPosition.Middle); speakerPositionEnum.value = CharacterScreenPosition.Middle; speakerPositionEnum.RegisterValueChangedCallback(e => { node.Properties.speakerPosition = (CharacterScreenPosition)e.newValue; }); //Create Conversant1 var conversant1Field = new ObjectField { objectType = typeof(Character), value = properties.Conversant1, label = "Conversant1" }; conversant1Field.RegisterValueChangedCallback(e => { node.Properties.Conversant1 = e.newValue as Character; }); node.Properties.Conversant1 = conversant1Field.value as Character; var conversant1PositionEnum = new EnumField(); conversant1PositionEnum.label = "Conversant1 On-Screen Position"; conversant1PositionEnum.Init(properties.conversant1Position); conversant1PositionEnum.value = properties.conversant1Position; conversant1PositionEnum.RegisterValueChangedCallback(e => { node.Properties.conversant1Position = (CharacterScreenPosition)e.newValue; }); //Create Conversant2 var conversant2Field = new ObjectField { objectType = typeof(Character), value = properties.Conversant2, label = "Conversant2" }; conversant2Field.RegisterValueChangedCallback(e => { node.Properties.Conversant2 = e.newValue as Character; }); node.Properties.Conversant2 = conversant2Field.value as Character; var conversant2PositionEnum = new EnumField(); conversant2PositionEnum.label = "Conversant2 On-Screen Position"; conversant2PositionEnum.Init(properties.conversant2Position); conversant2PositionEnum.value = properties.conversant2Position; conversant2PositionEnum.RegisterValueChangedCallback(e => { node.Properties.conversant2Position = (CharacterScreenPosition)e.newValue; }); node.mainContainer.Add(propertiesFoldout); propertiesFoldout.contentContainer.Add(bgField); propertiesFoldout.contentContainer.Add(speakerField); propertiesFoldout.contentContainer.Add(speakerPositionEnum); propertiesFoldout.contentContainer.Add(conversant1Field); propertiesFoldout.contentContainer.Add(conversant1PositionEnum); propertiesFoldout.contentContainer.Add(conversant2Field); propertiesFoldout.contentContainer.Add(conversant2PositionEnum); node.mainContainer.Add(sentenceTextfield); node.inputContainer.Add(inputPort); node.outputContainer.Add(outputPort); node.RefreshPorts(); node.RefreshExpandedState(); node.SetPosition(new Rect(Vector2.zero, nodeSize)); return(node); }