Question by
Gamingersp · Nov 19, 2017 at 12:46 AM ·
c#uitext
How can I make a typewriter effect?
How can i go about making a scrolling typewriter effect that has multiple paragraphs? I am having trouble with making my text scroll and also when i put in the text that i want it goes into one big paragraph. Here is my script so far: using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;
public class TypeWriterEffect : MonoBehaviour {
public float delay = 0.1f;
public string fullText;
private string currentText = "";
// Use this for initialization
void Start () {
StartCoroutine(ShowText());
}
IEnumerator ShowText()
{
for(int i = 0; i < fullText.Length; i++)
{
currentText = fullText.Substring(0,i);
this.GetComponent<Text>().text = currentText;
yield return new WaitForSeconds(delay);
}
}
}
Comment