Text Mesh Pro Ignores any "\n" present on string table entrys

How to reproduce:

1 - Create a new project.
2 - Import the localization and text mesh pro packages.
3 - Create a en(English) locale.
4 - Create a string table.
5 - Create a entry with the text : “My name is Bob\nIt’s raining today”.
6 - Using the GameObject menu creator, select “UI/Text -TextMeshPro”.
7 - Select the newly created GameObject.
8 - Click on the three dots to open the context menu.
9 - Click on “Localize”.
10 - On the Localize String Event component, assign the entry created on step 5 to the String Reference variable.
11 - Make sure the Locale Selector chooses the locale created on step 3.
12 - Make sure Rich text is active on the TextMeshPro component.
13 - Click on the Play button.

The text shown on the screen will be “My name is Bob\nIt’s raining today”, when it should actually be:
“My name is Bob
It’s raining today”.

PS: while on play mode, opening the “Extra Settings” tab on the TextMeshPro component, then toggling Rich text on and off will fix the text.

I don’t know if this is a problem with either the TextMeshPro or the Localization package, but i thought it would be a good idea to post this here since using “\n” works normally on TextMeshPro except when assigning the text through the Localize String Event component.

1 Like

Hey,
Could you please use the bug reporter.

Was there any temp fix or hacky workaround for this issue while waiting for a fix?

Its my personal biggest problem at the moment for changing over my project.

I think I see the problem. When you type the value into a text field it is treated as a string literal.
E.G \n becomes \n.
We need to convert them back. This is not done by default, we just pass the raw string.
What you can do is mark the String as a Smart String and check the **Convert Character String Literals** option. This will convert \ back into .

Then it will work

6587929--748390--upload_2020-12-4_8-58-11.png
6587929--748393--upload_2020-12-4_8-58-19.png

I spoke to the TMP developer. Seems like a long-standing issue in our TextFields. I’ll look into supporting this.

1 Like