Culling of GUI-elements and performance of GUI

hey all,
i want to display information above some GameObjects. so i calculate their position in screenspace with WorldToScreenPoint() and put a GUI.Label there. My question is now what happens with the Labels wich are not visible (ie outside the screen)? Are they culled automatically or should i take care of a visibility test for myself? or is this even necessarry because the test may take longer than rendering a text?

second question is a bit related. i have read that one should avoid using many GUITextures because of many costly DrawCalls. Does this also apply to GUIText and GUI.Label showing images (and sort of, everything handeled in OnGUI())?

thanks in advance.

Edit: is there a possibility to get the length (size) of a string on the screen in pixels? this would be great to center text.

Hey,

You can use GUIStyle.CalcSize for text width. Can’t give good answers to your other questions though.

And the style to use would be “Label” most likely. Like:

var style = new GUIStyle(“Label”); // cache this somewhere, don’t do it on every OnGUI
var label = new GUIContent(“Some string”);
then style.CalcSize(label).x is the width

and then GUI.Label(position, label, style);