IEnumerator DisplayDialougeText(DialogueObjecht _dialogueObjecht) { yield return(null); List <GameObject> spawnedDialougueButtons = new List <GameObject>();//deleting duplicat choices DialougeCanvas.enabled = true; foreach (var dialogue in _dialogueObjecht.dialoguetrees) { DialougeText.text = dialogue.dialougueText; if (dialogue.DialogueChocies.Count == 0) { yield return(new WaitForSeconds(dialogue.dialougueDisplayTime)); } else//opeing options panel ui { dialogueOptionsContainer.SetActive(true); foreach (var option in dialogue.DialogueChocies) { GameObject newButton = Instantiate(dialogueOptionsButtonPrefab, dialogueOptionsParent); //spawns dialoughe choice button spawnedDialougueButtons.Add(newButton); newButton.GetComponent <DialougeOptionUIButtonclick>().DialougebuttonSetup(this, option.nextDialogue, option.dialogueChocie); //loading in the dialoughe choice } while (!dialogueOptionsSelcted) { yield return(null); } break; } } dialogueOptionsContainer.SetActive(false); DialougeCanvas.enabled = false; dialogueOptionsSelcted = false; spawnedDialougueButtons.ForEach(x => Destroy(x));//destorying duplicate buttons }
public void DialougebuttonSetup(DialougeManger _DialougeManger, DialogueObjecht _dialogueObjecht, string _dialoguetext) { dialougeManger = _DialougeManger; dialogueObjecht = _dialogueObjecht; dialogueText.text = _dialoguetext; }
public void DialogueOptionsSelcted(DialogueObjecht selecteddialogue) { dialogueOptionsSelcted = true; LoadDialouge(selecteddialogue); }
public void LoadDialouge(DialogueObjecht _dialogueObjecht) { StartCoroutine(DisplayDialougeText(_dialogueObjecht)); }