- Home /
Problems with GUI relative coordinates once the game is published for web view
Hi.
I'm using a GUI script to construct an small menu in a certain section of the game. since coordinates are absolute, I too the precaution of scalling and placing my buttons with the proportions of the screen, for example:
private void RecalculateSizes() {
point.x= Screen.width * (100f - percentWidthButton)/(2f*100f);
point.y= point.y * Screen.height / savedScreenHeight;
dukButtonWidth= Screen.width *percentWidthButton/100;
dukButtonHeight= dukButtonWidth*dukButton.height / dukButton.width;
verticalSeparation= verticalSeparation * Screen.height / savedScreenHeight;
savedScreenWidth= Screen.width;
savedScreenHeight= Screen.height;
}
public void OnGUI () { if (savedScreenWidth != Screen.width || savedScreenHeight != Screen.height) RecalculateSizes();
if (GUI.Button (new Rect (point.x,point.y, dukButtonWidth, dukButtonHeight), dukButton, mySkinStyle.button)) {
}
}
Which looks perfect in my game view in web resolution (760 x 600), both when it's minimized and when it's maximized. But for some reason, buttons are dissplaced once my game is published for web. I have my web screen resolution set to 760x600 in my publish settings.
Thanks for any suggestions.
Answer by Ultratroll · Feb 10, 2011 at 08:26 PM
I ended ups setting my values so that the interface looks well in the final build but doesn't makes sense in my Unity's preview.
Kinda of bad solution, but well.
Your answer
![](https://koobas.hobune.stream/wayback/20220613103526im_/https://answers.unity.com/themes/thub/images/avi.jpg)