// Writes the given text to the screen public void Write(string t, npcSprite npc) { if (Time.time - timeLoc < textSpeed) { queue.Add(new Message(t, npc)); return; } if (sprite != null) { sprite.undrawZoom(); } if (npc == null) { sprite = null; } else { sprite = npc; sprite.drawZoom(); } text.Clear(); text.Add(t); textScroll = 0; timeLoc = Time.time; mesh.text = t; }
private int textScroll = 0; // Current location of text // Update is called once per frame void Update() { if (paused) { return; } // Scroll the text if (text.Count > 3 && text.Count - textScroll > 3 && Time.time - timeLoc > textSpeed) { string temp = text[0]; text.RemoveAt(0); text.Add(temp); WriteAll(text, sprite); timeLoc = Time.time; textScroll++; } // Show the next text message if there is one in queue else if (Time.time - timeLoc > textSpeed && queue.Count != 0) { WriteAll(queue[0].text, queue[0].sprite); queue.RemoveAt(0); } // Remove the text if (Time.time - timeLoc > 3) { text.Clear(); mesh.text = ""; if (sprite) { sprite.undrawZoom(); } } RedrawNPC(); }