- Home /
Scaling a GUI element to fit it's contents
I'm trying to scale a GUI.Box to size itself based on the size of the tooltip because they can differ quite a lot in size due to extra stats or more description text.
My current code for this is:
float dynamicSize = skin.box.CalcHeight(new GUIContent(tooltip), 200);
Event e = Event.current;
GUI.depth = -10;
GUI.Box(new Rect(e.mousePosition.x + 10, e.mousePosition.y, 200, dynamicSize), tooltip, skin.GetStyle("Tooltip"));
Unfortunately, this only scales it up slightly in size, and so the text of the tooltip ends up spilling out of the GUI.Box. Is there something I'm missing in terms of calculating the size for the box?
Comment
Your answer
Follow this Question
Related Questions
Scaling unity apps 1 Answer
smooth scailing (gui title image) 0 Answers
Scaling GUI correctly according to game window resolution? 1 Answer
How to scale a GUI (Lagacy) grid? 1 Answer
GUI.DragWindow causing Inventory Tooltip to stop showing 0 Answers