How to get character properties (width, height, position) from a text UI element?

Basically what I think I need is a way to measure font height. I’m not finding a lot in the documentation, but I think I’m looking in the wrong place.

I’ve made a quick video of my problem and why a content size fitter won’t work in my case:

@astracat111 , unfortunately I don’t know the answer to your question but I’ll offer an alternative approach which may or may not be useful in your application. Instead of using a single UIText object split the menu up into a title, “Hello there how are you doing?” and multiple choices each in a separate UI object. Each choice object will reside in a panel containing an image and a text box. The image will be either the arrow or a transparent placeholder. The text box will be the choice text. As you see in the picture below put the title on one panel and the choices on a second. Use a GridLayoutGroup on the choices panel so that the choices panels, each containing the image and text objects, will be automatically spaced. This allows you to access each choice individually through script. Your script will need to swap out the images and set the text as needed.

2 Likes