x


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.

more ▼

asked Feb 09 '11 at 03:13 PM

Ultratroll gravatar image

Ultratroll
103 12 13 19

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Feb 10 '11 at 08:26 PM

Ultratroll gravatar image

Ultratroll
103 12 13 19

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3684
x811
x111
x104
x95

asked: Feb 09 '11 at 03:13 PM

Seen: 805 times

Last Updated: Feb 09 '11 at 04:10 PM