How can I break an UIText on OnClick of an button without scripts ?


I’m looking here on the answers and on the google, but on my searches I can’t reach nothing.

I’m trying to replace an UIText content on button event OnClick.

It work, but, without break lines.

It’s possible ?

To explain:

I have an simple scene, with 2 buttons and 1 text.

each button change the text, and I can’t have more than one UIText, I need to put all in the same UIText.

My UIText was created like this:


But, on the text I have an big area to write and here I can hit ENTER.


Then, I put the event OnClick to change the text, bu here I have only one line to write…

alt text

And, when I hit the button, my text change to:

alt text

How can I do the break line here ?
Or it’s impossible and I need to really use script ?

My unity version is:

alt text

Very thanks for your time and your help.

I don’t believe that it is possible to do this within the editor as the typical line break notifier "
" is recognised only as text to the inspector.

I believe that your best bet is probably to create a script that reads your texts and replaces any "
" text with
which should count as a return key.

For example:

string newString;
Text textBox;

void ReadText()
newString = textBox.text.Replace("\

", "
textBox.text = newString;

The above code will read your string and replace any "
" with "

So if you want to add a return to your text, type "
" in the place you want a line break, and this script will go in and replace that via code with "
" which counts as a line break.

It’s stupid I know, but that’s just how the text is interpreted.

Very Thanks, @TheBlackBox, I don’t want to use scripts, but an generic script changing an word key to line breaks already help-me.
I try here and with "
" my text return with line break and a "" in my text, then I only change the keyword and work perfect.