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
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.