|
My goal here is to use GUILayout to render a label that has a background that automatically resizes itself to fit its contents (the text). This the only way that I know of to make sure the background texture is as long as the text. This label will serve as a tooltip that follows the mouse cursor. There's two main problems here:
Here is some code. This function is called after all of my widgets have been drawn. Some widgets specify a tooltip, some don't.
Anyone know how I can get this working properly? UPDATE I figured out why this isn't working. Apparently GUI.tooltip is an empty string when OnGUI is called for Layout only (Check Event.current.type for the "Layout" event). However, on the repaint event, it is the valid tooltip. Because the string (GUI.tooltip) is empty during layout, the widgets cannot size to their content properly.
(comments are locked)
|
|
What you've got seems pretty close, but you might also need to add some flexible space to the vertical, e.g.
If the width of the label still does not adjust, make sure your style has "fixedWidth" set to 0 (i.e. no fixed width, allow adjustment). This still doesn't work. The label's size isn't adjusting when text is added. If I remove the flexible spaces then the text does indeed show up, but it has no affect on the over-all sizing algorithm for some reason. I have also made sure that fixed width/height are set to 0 in the GUIStyle.
May 21 '10 at 06:58 PM
Robert 1
(comments are locked)
|

I see, I thought the question was with sizing; I tested with a different string for convenience.