- Home /
GUI button adjustments
hi to all....
am facing a rare problem,it is very silly to see....but try to help me !
i created 5 buttons . it is exactly visible when the browser ( chrome,opera,IE,Mozilla ..etc) when browser zoom is 100 %. but when i change the browser zoom (90%,80%,150%.....etc),the gui buttons are not visible on the screen.
i want those GUI buttons always at a particular position,even if i change the browser zoom.
please help me !!!
are the GUIButtons based on the screen width or are they fixed positions. Could you post a snippet of code of the buttons?
Well then that's your problem! You need to define all your positions in terms of Screen.width and Screen.height- this will guarantee that all your buttons retain a sensible scale on the viewport.
Answer by Lttldude · Apr 19, 2012 at 06:06 AM
Here is an example of making GUI elements relative to the screen size:
function OnGUI()
{
var sW = Screen.width;
var sH = Screen.height;
GUI.Box (Rect (0,0,150,30), "Top Left Corner");
GUI.Box (Rect (sW-150,0,150,30), "Top Right Corner");
GUI.Box (Rect (sW-150,sH-30,150,30), "Bottom Right Corner");
GUI.Box (Rect (0,sH-30,150,30), "Bottom Left Corner");
}
Hope it helps, be sure to ask if you still have issues.