Sign in to follow this  

Gui: in percents or in pixels?

Recommended Posts

thecheeselover    565
Hi there,

I was wondering if it was better to set the Gui in function of how many pixels are on the screen (a percentage) or if it was better to set the Gui in function of a fixed resolution. If the resolution of the Gui is fixed, Gui elements won't scale if the actual resolution is different from the fixed one. If Gui elements use a percentage, they will scale depending on the actual resolution. What do you think is better?

Thank you,

Share this post

Link to post
Share on other sites
Corefanatic    176
Generally, making a UI system pased on percentages or using universal coordinate system (ie. top left corder of any window is (0,0) and bottom right is (1,1)) is better since your UI will scale automatically, but set pixels is faster to implement.

I honestly think that best solution is one that incorporates both, for example if you want a console window in your ui, you might want it to scale to width of your window automatically, but you might want it to extend down only 300 pixels no matter what the resolution is (as long as it is more than 300 vertically of course).

Web pages implement both of these together and they work pretty well so take your inspiration from them.

Hope this helped.

Share this post

Link to post
Share on other sites
Adam_42    3629
Ideally you want to support all sensible aspect ratios and resolutions. A basic set might be something like: 640x480, 1280x1024, 1920x1200, 1280x720.

You should be able to handle those without hard coding it for each one. That probably means you need positions and scales that are percentage based, but also have an origin that can be moved (e.g. some things might be placed relative to the bottom left corner of the screen, and others relative to another UI object).

Some people also like to run in windowed mode which ideally they can be stretch to almost any aspect ratio, although you can prevent / limit that.

Of course doing all that can be a lot of work especially if there's lots of 2D UI, so it can make sense in some cases to simply add black borders and have everything run at a fixed aspect ratio, or even fixed resolution.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this