0
Not a Bug

How to put a new line (/n) in a string?

mnraart 2 years ago updated by Lazlo Bonin (Lead Developer) 2 years ago 9

I am trying to fill a ui text field with some string that I combine with the concat function. But I need a way to break a line like <br> or /n but these won't work

Bolt Version:
Unity Version:
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):

You need to make sure you have system added to assemblies, and then Environment added to types. You then have to use the Newline reflected unit itself. Environment.Newline with a Add Generic attached to your other text. I believe this happens because reflection is not compiled, which symbols like that need to be compiled. So there is the type for this reason.

Thanks for your reply. I added system to assemblies but cannot find the environment type that you suggest. none of the ones in the picture have the new line function.



What version are you on. You will have to upgrade to 1.3 if your not, or not use AOT Safe Mode. There was a bug with static classes that got fixed. Environment being static.

+1

Thats it. I upgraded to 1.3 and now I have the environment type with the new line function :)

Thanks a lot.

Excellent glad it worked!

+1

if you use Textmesh Pro, you can just add <br> to the string

Nice tip, I have never looked into that. Just used as is. This works assigning a string literal? That's pretty cool.

+1

it's a new feature, added a month ago. you had to use the Environment method before