Get Text Width

in my game i need show a talk dialog,I use the Text component to show letter,but in the letter there is some smile image(fixd width),these letter show one by one, How can I do this? i need get the text precise width to position the image,but I can’t find a function in the Text component,how to do this?

I don’t know the ‘correct’ way to do it, as I could not find the text size accurately until the next frame when it’s been positioned/fit.

Set text
Coroutine wait endOfFrame
Either the panel the text is in, or the text itself (which is what I think you want) - rectTransform.rect.width

i need the real text width,not the rectTransform.rect.width,infact the rectTransform.rect.width is large than the real text lenght

A possible solution is to have a font material which translates several unneeded symbols into emoticons or smile images. Thus, you will be able to insert them into dialogs without having to worry about scaling the text to fit the emotions.
Good luck,

Hi louisgv,infact i only want to use system font, how to make a material to translates several unneeded symbols into emoticons ?

I have try make a bmp font,it really work fine ,use material i can show letter and emoticons,but I find another problem,the character can’t wrap , i’m sure i have set the “horizontal overflow” to “Wrap”,and the Text rectTransform.rect.height is enough,but the text don’t change line ,why?

Just in case you are open to alternative suggestions.

Works with the new UI and allows you to add Sprites inline with the text. Sprites are added by using the <sprite=xx> tag where X is the sprite index in the Sprite Asset.

Since the sprites are treat just like any other character, word warping and all other tags and things affecting characters also affects those sprites.

As you can see in the GIF, the text is revealed one character at a time, respecting word wrapping.

This is just one of the things that TextMesh Pro offers. Just let me know if you want more information.