I’m having a problem with misaligned sprites in TextMesh Pro. All the sprite sheets are generated with Texture Packer and exported to a unity sheet and json array so it can be imported to TM Pro with the Sprite Importer. The emoji’s are properly read and display fine but they are misaligned a little too low and to the right. The default Sprite Sheet is fine and another sprite sheet I made is also fine. I imported the raw sprite sheet and configured it manually but it’s still the same problem.
Is there a limitation to the way sprites are packed for TM Pro?
I’ve attached my sprite sheet and JSON array file that I am using in a zip file, Thanks!
PS: This is easily fixed by manually adjusting positions in the asset file, but it’d be ideal to know what may be causing this for larger sprite sheets in the future.
3354398–262523–Emojis.zip (103 KB)
The position of the sprites in the text is relative to their pivot point. Given that your sprites have a pivot of (0.5, 0.5), they will be drawn with the pivot at the origin point which is at the xAdvance of the previous glyph and on the baseline.
If the pivot point defined for these sprites in Texture Packer was (0, 0) then the sprites would be placed on the baseline and at the xAdvance of the previous glyph.
To adjust the position of the sprites relative to the text. You could change the pivot point of your sprites in Texture Packer to be at (0, 0) or bottom left corner.
Alternatively, you could simply open the Sprite Asset Editor and using the GLobal Offsets and Scale at the bottom of each page, adjust the OY (Offset Y) of all the sprites in the Sprite Asset.
In this editor panel, you can adjust individual sprite in terms of their x, y position relative to the text as well as their advance value. You can also adjust their relative scale to the text.
I suggest you take the time to watch the Sprite Asset Creation video which covers all these options.
5 Likes
I had to apply strange values for OY to get the emoji centred.
They are 128 pixels high, but I had to set the OY to 105 for them to look centred vertally.
1 Like
Sprites are positioned relative to the pivot of the sprite as defined in the Sprite Editor. They are then offset by the X Bearing (OX) and Y Bearing (OY).
1 Like
The pivot is set to 0.5 and 0.5 in the sprite editor, right in the middle of each emoji. But when I render the text with OX and OY as zero… The emoji render much lower than the text. The correction of 105 seems to be a strange value…
The pivot position defines the Origin of the sprite. New glyphs or sprite glyphs are positioning at the advance position of the previous glyph on the baseline.
In the case of the pivot / origin being (0.5, 0.5), the sprite without any offset X & Y will be positioning as seen below.

6 Likes