Quantcast
Channel: Questions in topic: "measure"
Viewing all articles
Browse latest Browse all 91

How long is a string?

$
0
0

"How long is a piece of string?" may be a rhetorical question, but I'm hoping there's an answer to "How many pixels long will my string be when rendered into a GUI.Box?"

I want to grow my box to make it big enough to fit my string. GUI.skin.box.lineHeight * numberOfLines tells me how tall it will be, but there's no equivalent for character width. (And since not all characters are the same width this wouldn't work anyway.)

What I want is something like the MeasureText methods in Windows Forms.

As a workaround for now I'll split the string into lines, find the longest line, and multiply by an average character width.


Viewing all articles
Browse latest Browse all 91

Trending Articles



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