public void SetNewDialogOption(int i) { // "Crashes" the dialog if a value is called which doesnt exist. // Also throws out if an end leaf is reached. if (!IsIdInRegistry(i) || allEndLeafIDs.Contains(i)) { OpenGamestate(); return; } previousDialog = currentDialog; currentDialog = GetEntityById(i); if (currentDialog is DialogText) { SetupUI(currentDialog as DialogText); } else if (currentDialog is Choice) { SetupUI(currentDialog as Choice); } else { // If it's not a text oriented option, execute immediately SetNewDialogOption(currentDialog.ExecuteNodeAndGetNextId()); return; } }
public void SetupUI(DialogText option) { button.gameObject.SetActive(true); button1.gameObject.SetActive(false); button2.gameObject.SetActive(false); display.text = option.text; button.onClick.RemoveAllListeners(); button.onClick.AddListener(() => SetNewDialogOption(currentDialog.ExecuteNodeAndGetNextId())); button.GetComponentInChildren <Text>().text = "Next"; }