Quantcast
Channel: Latest Questions by x4000
Viewing all articles
Browse latest Browse all 49

Is there a way to measure the pixel with/height of a string with a given font?

$
0
0

I see the GUI Layout stuff for automatically laying out UIs in certain ways. And that is pretty cool overall. However, it is also really helpful to be able to precisely center various arbitrary strings (arbitrary thanks to localization or other factors, which has been an interesting challenge for me in past projects). With both DirectX and GDI, there is essentially a MeasureString method that you can pass a font, some text, and a max width to, and it gives back a Size property saying how wide/tall that text will be given the parameters you passed in. Surely there's something similar in Unity?


Viewing all articles
Browse latest Browse all 49

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>