- Home /
Making text appear from the bottom up
Hey!! I'm trying to get text to appear on screen line per line in quick succession (command prompt style). I'm stuck at trying to make the top line of text disappear when the new line appears at the bottom of the text box. This is what I have so far:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class TypeWriterEffect : MonoBehaviour {
public float delay = 0.1f;
private string currentText = "";
public TextAsset asset;
void Start ()
{
StartCoroutine(ShowText());
}
IEnumerator ShowText(){
string[] lines = asset.text.Split('\n');
for (int i = 0; i <= lines.Length; i++){
this.GetComponent<Text>().text = currentText;
currentText = currentText + "\n" + lines[i];
yield return new WaitForSeconds(delay);
}
}
} Thanks for any help!!
Comment
Your answer
Follow this Question
Related Questions
4.6 UI Text rect does not expand automatically 2 Answers
How do i make a TextArea Descend when messages happen 0 Answers
How to solve solve UI text size too small? 1 Answer
Making Credits Scroll Upwards on Screen 2 Answers
Scrolling Text 1 Answer