Weird TextMesh Pro Behaviour [Possible Bug]?

Hi all,

I get this interesting behaviour when I use TextMesh Pro (3D text) in my game.

It should be “33 - Black - Odd”. The alignment of the TextMesh is Center-Middle.

When the game starts, the text is invisible first (the alpha value of the text is 0). When a result arrives, I use this string format to set the text: “{0} - {1} - {2}”, and change the text’s alpha to 1. As a result, it looks like the image above. If I pause the game and fill the text manually in the editor, it works normally.

It looks like every word (33, Black and Odd) is aligned in the middle.

Why does this happen? How can I solve this problem?

EDIT: Also, the text shows the preferred width wrong. It shows 1.65, but when I fill the text manually, it shows 2.96. It looks like a bug

Do you have any control characters in the text?

What is the exact resulting string you are using?

There is no control character in my string

When I debug the string it shows the full string: “33 - Black - Odd”. The string value is not wrong.

I basically get a result from the server and create a string depending on the result and the localization. Here’s simplified version of the code:

    private static readonly string Format = "{0} - {1} - {2}";
    private static readonly string Red = "red";
    private static readonly string Black = "black";
    private static readonly string Even = "even";
    private static readonly string Odd = "odd";

        //... 'result' and 'isRed' values have been set

        // localizedText variable is a string-string dictionary that contains translated strings
        Text.SetText(string.Format(Format, result, isRed ? localizedText[Red] : localizedText[Black], result % 2 == 0 ? localizedText[Even] : localizedText[Odd]));

Also, I realized that if I remove the Odd-Even part from the string.Format function, the text works normally. The last part breaks the TextMesh Pro

EDIT: The “- Odd” part of the string is top of the "33 - Black " part.

There has to be some control / hidden character in there. If you inspect the string in the debugger what are the unicode values of these characters? Are the exactly what you expect or is something else getting injected in the data coming from the server?

I only return an integer value (33 in this case). Black/Red and Odd/Even part is coming from the dictionary. The dictionary is created with a CSV file and in the CSV file, the related texts are like this:

black,Black
red,Red
even,Even
odd,Odd

The interesting thing is that it’s broken if I include the last Odd/Even part.

Anyway, I changed my game design, and now, I only show the number in the game

Without being able to verify the exact content of the text to check what unicode values are used in the string, I can’t explain exactly why you are getting this behavior.

If you want to know and can submit a bug report with the project and steps for me to reproduce this, I will be more than happy to take a closer look.