Get Width/Height Of String Outside of OnGUI Method

Hi,

I need to find the width and height of a string. I have tried

Vector2 widthAndHeight = GUI.skin.label.CalcSize(new GUIContent("some string"));

But CalcSize is only callable from the OnGUI() method. I need a way to find the width/height outside of the OnGUI method.

Thanks for any help in advance!

can’t you just save to variables the info whenever the shown text is changed? I mean OnGUI is called anyway.