IEnumerator readText(string line, Color color, Character speaker, AudioClip voiceLine, IEnumerator cont, bool bark) { var temp_string = line; mainDialogue.text = ""; switch (speaker) { case Character.player: if (voiceLine) { voiceGirl.PlayOneShot(voiceLine); } break; case Character.date: if (voiceLine) { voiceGirl.PlayOneShot(voiceLine); } break; case Character.dog: if (bark) { StartCoroutine(woofer.woof(temp_string, voiceGirl)); } break; } mainDialogue.color = color; mainDialogue.GetComponentInChildren <Image>().enabled = true; mainDialogue.text = temp_string; mainDialogue.maxVisibleCharacters = 0; while (temp_string.Length > 0) { yield return(new WaitUntil(() => playerIsWatching.val)); if (temp_string[0].Equals("{")) { string dur = ""; for (temp_string = temp_string.Remove(0, 1); !temp_string[0].Equals("}"); temp_string = temp_string.Remove(0, 1)) { dur += temp_string[0]; if (temp_string.Equals("")) { Debug.Log($"unmatched curly brace }} at line: {line}"); } } temp_string = temp_string.Remove(0, 1); int actual_dur; if (int.TryParse(dur, out actual_dur)) { yield return(new WaitForSeconds(.1f * actual_dur)); } else { Debug.Log($"Pause duration is not in the form of an int in line: {line}"); } if (temp_string.Length == 0) { break; } mainDialogue.text = temp_string; } //mainDialogue.text += temp_string[0]; mainDialogue.maxVisibleCharacters++; temp_string = temp_string.Remove(0, 1); yield return(new WaitForSeconds(1f / textSpeed)); } yield return(new WaitForSeconds(1.75f)); yield return(new WaitUntil(() => !voiceGirl.isPlaying)); if (ChatHistoryRightScreen != null) { StartCoroutine(EnterChatHistory(line, color, speaker, ChatHistoryRightScreen, Vector3.zero)); } if (ChatHistoryLeftScreen != null) { StartCoroutine(EnterChatHistory(line, color, speaker, ChatHistoryLeftScreen, new Vector3(-10.8f, 0, 0))); } StartCoroutine(cont); }