Default GUIStyle

How do I get the default GUIStyle? I need to measure a label's height I draw with

GUI.Label(new Rect(0, 0, 100, 500), "Some very long text");

And I don't specify a GUIStyle so I can't use it's CalcHeight, How do I find the GUIStyle it will use so I can use the CalcHeight?

(Don’t tell me the height will be 500 - it’s just a placeholder until I can get the measurement)

1 Answer

1

You can use this:

public void OnGUI()
{
   var content = new GUIContent("Some very long text");
   var size = GUI.skin.label.CalcSize(content);
   GUI.Label(new Rect(0, 0, size.x, size.y), content);
}