Cannot get newline to show in guitext from script

I am trying to insert a newline into a guitext from a script, but it doesn’t show up.

I have tried adding , System.Enviroment.NewLine and a string containing a literal newline but none show in the guitext.

The strange thing is when I output the contents of the guitext to a log file and open it, the newlines are there.

Anyone have any idea what the problem could be?


The demo can be found here.

And here’s the code I’m using, with the end goal of text wrapping the text to the size of the background, and then outputting it character by character. Also, just isolated the problem to the second part that outputs the text character by character.

IEnumerator TypeWriter()
	string[] words = currentNode.text.Split(' ');
	for (int w = 0; w < words.Length; w++)
		if (w > 0)
			guitext.text += " ";
		guitext.text += words[w];
		if (guitext.GetScreenRect().width >= guitexture.GetScreenRect().width * .8f)
			guitext.text.Remove(guitext.text.Length - words[w].Length + 1);
			guitext.text += newline + words[w];

	guitext.text = "";
	for (int i = 0; i < currentNode.text.Length; i++)
		guitext.text += currentNode.text*;*
  •   	yield return new WaitForSeconds(typewriterInterval);*
  •   }*
  • }*

If you set a variable from code, it’s
, if you set it in the inspector, you can try a [Multiline] Attribute, to get a multiline text field.

Are you sure your GUIText is big enough to show both lines?