- Home /
Public text to multi line
Hello, so I have this public text, which is created from the code and assigned to my main Manager. In the inspector I write the text here manually, but the text is single lined, how can I change it to multiline? I looked up that I have to use it as public string, but when I do that, I cant use the .text parameter to pass values.
public text InformationTxt;
InformationTxt.text = QnA[currentQuestion].Information;
These are the lines I used in my code.
Answer by Bunny83 · Apr 26, 2021 at 08:23 AM
Unity has some built-in attributes and property drawers you can use. Specifically the Multiline attribute.
So in your definition you just do
[Multiline]
public string Information;
and it should show this string field as a multiline field. I'm not sure what this has to do with the UI Text component. The Text component has a property called .text
where you can assign a string that should be displayed. AFAIK the text should have just "\n" as line breaks, but its been too long ago I actually used the Text component ^^.