- Home /
[solved] print a multiline text in a GUI
hello all I have a great request, I have a script for read all line in a txt via a html adress, all the text was write in: public StringBuilder sb = new StringBuilder();
in my GUI I write this code:
GUI.Label(new Rect(10, 10, 100, 20), reader.sb.ToString ());
but only the first line was print.
How to print multi line?
thanks you in advance
$$anonymous$$ake sure the text has newlines to break the lines. Also you've made your GUI.Label() only 20 pixels high.
the height on the GUI, I replace 20 by 200 and magic it's work
Answer by Xtro · Jul 25, 2014 at 06:02 PM
Put '\n' into the string.
Ex :
"This is first line\nThis is second line"
bug I read a text from http link so I can't modifie the value
You'll have to work out how to modify the text you get from the URL. $$anonymous$$aybe it has line endings which don't apply.
Answer by isador34 · Jul 26, 2014 at 02:20 PM
in my txt file I write: 1\n2\n3\n4
But on my GUI same the \n was write...
Text files are encoded. C# strings are not. '\n' only work in strings. In a text file, you should press enter to make a new line and when you read/write this file to the screen it should break the line as expected. Ofcourse the platform you are writing onto must support multi-lines.
"GUI.Label" supports multi-lines. If your file has multiple lines, it should be working correctly.
Do you wanna attach the text file here ?
Your answer
Follow this Question
Related Questions
How do i take a string from a gui and show it in the gameworld c# 1 Answer
Problem with makeing text appear on screen 0 Answers
IF in a GUI 2 Answers
Detect Text in GUI; Print 1 Answer
format text block in GUI.Box 1 Answer