private void OnButtonClick(NodeLinkData linkData, DialogueCondition conditionToToggle) { if (conditionToToggle != null) { conditionToToggle.ToggleValue(); } BaseNodeData nextNode = GetTargetNode(linkData); PlayNode(nextNode); }
private void GenerateChoiceButtons(DialogueNodeData node) { List <NodeLinkData> nodeLinks = GetLinks(node.guid); if (nodeLinks.Count != node.responses.Count) { Debug.LogError( $"Dialogue Node {node.guid} has mismatched number of links and responses. Aborting conversation."); dialoguePanel.gameObject.SetActive(false); return; } for (var i = 0; i < node.responses.Count; i++) { NodeLinkData link = nodeLinks[i]; string currentResponse = node.responses[i]; DialogueCondition conditionToToggle = node.conditionsToToggle[i]; Button button = Instantiate(choiceButtonPrefab, choicesContentAreaTransform); button.GetComponentInChildren <TMP_Text>().text = currentResponse; button.onClick.AddListener(() => OnButtonClick(link, conditionToToggle)); } }