using System.Threading.Tasks; using UnityEngine; using UnityEngine.UI; namespace That_One_Nerd.Unity.Games.ArcadeManiac.Minigames.TheAverage9To5Job { public class TextRenderer : MonoBehaviour { private Text txt; private void Awake() { txt = GetComponent(); Flush(); } public void Flush() => txt.text = ""; public async void WriteText(string content, int msDelay = 20, int mouseDownDelay = 5) { for (int i = 0; i < content.Length; i++) { await Task.Delay(Input.GetMouseButton(0) ? mouseDownDelay : msDelay); txt.text += content[i]; } } } }