Quantcast
Channel: Latest Questions by hkessock
Viewing all articles
Browse latest Browse all 51

GUIStyle.CalcSize appears to break when your style specifies padding

$
0
0
I have a GUIStyle derived from GUI.skin.label. I set a few properties on that style such as the alignment and fontsize, then I iterate through fonts sizes until I find the largest font that will fit my rect. This works great, right up until the point I put padding around the label, then CalcSize goes beserk returning back heights that are orders of magnitude larger than the actual height. l_oLabelStyle.alignment = TextAnchor.MiddleCenter; l_oLabelStyle.fontSize = 36; The above has no problems with CalcSize. l_oLabelStyle.padding = new RectOffset( 30, 30, 30, 30 ); The line above causes everything to go haywire. The CalcSize seems to be returning back a reasonable width in this case, but the height is astronomically large. Without touching the padding, I get back a reasonable height of 47. With padding I get 3936 for the height... Other caveats are that I am using setting GUI.matrix elsewhere to scale my GUI code to the runtime resolution. The scale is roughly 0.5 on X and Y. Anybody run into this before?

Viewing all articles
Browse latest Browse all 51

Trending Articles