0
Pending Review

Entering escape sequences in strings

Alex 3 years ago updated by JasonJonesLASM 3 years ago 3

Dear Lazlo,

well well done, the whole stuff!!! :-)

I came from Autodesk Stingray and recognize that your Bolt is much more powerful! Congrats!

I have a quick question:

How may I enter a "carriage return" in a string that is send to a text mesh via SetText???

Unity says \n but this doesn't work...


Best regards,

Alex

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

\n indeed does not work, guessing because of how Bolt parses things. The way to accomplish the same thing is to use generic addition or formula to add your text and newline. Newline can be found by adding System and then In types I believe it's Environment.

+1
Pending Review

I think this would be a rather easy feature to implement, but it would have the downside of having to parse every string all the time at runtime to look for escape sequences, which could be a small hit on performance. I'll keep it under review and try to think of a way that wouldn't negatively affect performance.

Might not be the best way all around (can't be used directly in the string on a unit), but a simple parseable string unit itself? or you could modify the string literal somehow with a parseable option? Like how you have options for fallbacks and such in the inspector, that way if it is unchecked, it'll be false and not run the contents of the check. I could always whip up a unit in the meantime as a standalone unit, if you'd want something better down the road. Shouldn't be too difficult.