/// <summary> /// Play a sequence of dialogue /// </summary> /// <param name="index"> The start id of dialogues </param> /// <returns></returns> public IEnumerator PlayDialogue(int index) { GUIDialogue dialogueWin = (GUIDialogue)GUIManager.Singleton.Open("DialogueUI"); dialogueWin.GetComponent <Canvas>().worldCamera = Camera.main; dialogueWin.CurrentTimelineManager = currentTimelineManager; if (CheckDialogueType(index) == DialogueType.Normal) { dialogueWin.DisplayDialogue(dialogues[index].Text, dialogues[index].Actor); } else { yield break; } yield return(null); while (dialogues[index].Next != "-1") { Debug.Log(LogUtility.MakeLogStringFormat("DialogueManager", "Enter Loop")); //wait for next line yield return(waitForKeyPress(KeyCode.G)); if (dialogueWin.CheckAnimateCoroutine()) { dialogueWin.SetSkip(true); yield return(waitForKeyPress(KeyCode.G, dialogueWin)); dialogueWin.SetSkip(false); } int nextDialogue = Convert.ToInt32(dialogues[index].Next); if (CheckDialogueType(index) == DialogueType.Normal) { dialogueWin.DisplayDialogue(dialogues[nextDialogue].Text, dialogues[nextDialogue].Actor); } else { yield break; } index = nextDialogue; } yield return(waitForKeyPress(KeyCode.G, dialogueWin)); GUIManager.Singleton.Close("DialogueUI"); if (currentTimelineManager.CheckEndState()) { currentTimelineManager.OnTimelineEnd("Moving"); } DialogueEnd.Invoke(); }