GUI scaled to perfect square on 16:9 screen ratio?

If my only screen ratio is 16:9, how do I figure what numbers to use with screen.width* and screen.height*, in order to get a perfect square?

I think I figured it out. It is pretty easy actually. Just divide by resolution quantities.

EX.

(rect(Screen.width/#,Screen.height/#,Screen.width/16, Screen.height/9)

or

(rect(Screen.width/#,Screen.height/#,Screen.width/8, Screen.height/4.5)

see, all I did was divide the resolution 16:9 by 2 equally, keeping a perfect square. You could apply this to other screen ratios also.

Hope this helps someone!

If you know that you’re always going to have a 16:9 ratio, you can just choose either screen.width or screen.height for your ratios.

For example, you can base your GUI off of a resolution of 1920x1080 and get everything the right size for that screen. Then, to scale it down (or up), use the ratio between the current screen height and the screen height the GUI was designed for.

Thus: if you have a 100x100 pixel square and it’s the right size on a 1080p screen, you can scale it down correctly for a 720p screen by:

100 * (720/1080);

Or more generically, you have a ratio that you apply to all of your GUI elements. (Example uses C# syntax)

public float designedScreenHeight = 1080.0f;

public float guiRatio {
    get {
        return screen.height / designedScreenHeight;
    }
}