How to handle UI Toolkit Text Sprite Asset placement??

Hello,

There seems to be an issue with sprite asset alignment inside text in UI Toolkit or I’m doing something wrong.

My sprite is setup with the pivot in the center, but the pivot doesn’t seem to even affect the final result. The sprite is placed beside the previous text character from the center so the left half of the sprite overlaps the previous characters in the text and the right side of the sprite has a buffer the size that you would expect from the half width + mini buffer. I am currently compensating by adding 4 spaces before the sprite which more or less gives a matching space on either side.

For the below, the sprite will overlap the last “bla” by half the width of the sprite and the right side of the sprite, before the word “said”, will have a space the size of half the width of the sprite plus a small buffer more or less:

"Bla bla bla<sprite="spriteName" name="spriteName">said the fox"

Am I doing something wrong here??

1 Like

I have exactly same problem

In Unity 6 pivot can be set in this. It´s hidden on bottom of paged Spirite Glyph Table that does not makse sense… click it open and scroll to bottom of page
image

Hi! Sorry for the late reply.

You can adjust the pivot directly on the SpriteSheet. In the Sprite Inspector, open the Sprite Editor to modify the pivot for each sprite.

Once you create a SpriteAsset from the sprite, the following metrics will automatically reflect the pivot set in the Sprite Editor.

Let me know if this helps!