My understanding is that GUIStyle.CalcSize is supposed to return the pixel size, in the given style, of the content given in the argument. However, the answer that CalcSize gives me is much larger than the actual size of the text onscreen.
Debug.Log (ScoreStyle.CalcSize(new GUIContent("HH")));
GUI.Label(new Rect(10,10,190,40), "Best: " + highScore, ScoreStyle);
In the above code, for example, logs (52.0, 36.0) to the console, but the glyphs rendered by GUI.Label are only 21 pixels tall.
What could cause such a discrepancy? I'm not using anything like GUI.matrix, and the font isn't using padding or anything.
Oh, and also the font I'm using is caps-only, so there are no descenders, and the height of each glyph is the same.
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a user guide.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
For troubleshooting common problems with Unity 5.x Editor (including Win 10).
Answers and Comments
9 People are following this question.
Is there a way to measure the pixel with/height of a string with a given font?
Sometimes the GUI selectively doesn't render some letters
How can I add font effects to my GUIStyle font?
How to calculate the height of wordwrapped gui text
GUIStyle for GUI.label doesn't work for android?