AlanMP
1
I can add line breaks in editor with shift + return, but can’t work out how to do the same when setting the text with this.entity.element.text
I’ve tried inserting \n
and <br>
, with no luck…
Is it possible to add a line break to text set programmatically for the new UI text elements?
vaios
2
Hm it seems to work for me if I do something like:
this.entity.element.text = 'one line\ntwo lines';
AlanMP
3
Huh, weird, I swear it didn’t work when I tried it a sec ago…
Definitely works now though, cheers!
1 Like
It seems that if you’re setting text from a custom script attribute (of type string) then \n does not generate a new line. Weird!
Yurii
5
I just fixed it this way:
this.entity.element.text = myText.replaceAll("\\n", "\n");
Same here! Did you found a workaround about this?