as the title says the vector2 im getting back is way off. it should be something around (100, 30)
(14.0, 214.0) UnityEngine.Debug:Log(Object) is what im getting in the console...
any ideas whats going wrong?
The problem is that CalcSize doesn't work correctly whenever word wrapping is enabled. The doc already states that "This function does not take wordwrapping into account". What it fails to mention is that it returns completely wrong values when word wrapping is on. Now, since wrapping is on by default in some skins, you need to turn it off explicitly in order to use CalcSize. For example, to center some text on the screen:
Alternately, you could enable word wrapping, define yourself the width your text should have, then use CalcHeight to get the corresponding height:
I am getting the same problem. The CalcSize is giving me (14,0 , 24.0) as a Vector2 return when my block of text easily fills a 730.0 wide and 400.0 tall box on the screen.
Edit: I could not find the solution for this
I have a GuiContent element with text.
CalcSize now returns a Vector2 (2400.0, 24.0)
CalcHeight, width 700, called on that same GuiContent should return 96 (4x 24)
CalcHeight however always returns 24.0 regardless of the width. Not sure why.
I ended up just using CalcSize and calculating my own height from that.