- Home /
Question by
Decstar_G · Jun 19, 2016 at 08:30 PM ·
c#unity 5scripting problemgui
Create more text in unity GUI? (C#)
I am going to ask this quick question. Say you had something like this: GUIContent content = new GUIContent("Text");
void OnGUI() {
GUI.Box(new Rect(0, 0, Screen.width, Screen.height), content);
GUI.Button(new Rect(0, 20, 100, 20), "Button")
}
How would you add a new line of text to the content multiple times? (Working consistently)
Comment
You should definitely consider moving to post 4.6 Unity UI, the technology you are using is obsolete.
Answer by saschandroid · Jun 20, 2016 at 06:50 AM
You should follow smallbits advice and use the new unity ui, but to answer your question: You could do something like
void OnGUI()
{
GUI.Box(new Rect(0, 0, Screen.width, Screen.height), content);
if (GUI.Button(new Rect(0, 20, 100, 20), "Button"))
{
content.text += "\nmore Text";
}
}
Answer by JedBeryll · Jun 19, 2016 at 08:35 PM
" \n " is the new line character. I can't check if it works right now but I think it should.