- Home /
Question by
matthewosb003 · Mar 09, 2020 at 07:30 PM ·
uitext
Writing text to UI Text new line
I desire to write text to a new line in every loop currently it just writes on line 1, Is there a way I can write from line "i" ... I'd look this up but To be honest I don't know what to look for.
IEnumerator PrintText()
{
for (int i = 0; i < lines.Length; i++)
{
yield return new WaitForSeconds(1);
textField.text = lines[i] + "\n";
}
}
Comment
Best Answer
Answer by Hellium · Mar 09, 2020 at 09:05 PM
I may not understand correctly, do you want to progressively display a text, line by line? If so:
IEnumerator PrintText()
{
WaitForSeconds wait = new WaitForSeconds(1);
textField.text = lines[0];
for (int i = 1; i < lines.Length; i++)
{
yield return wait;
textField.text += "\n" + lines[i];
}
}