Jump to content
  • Advertisement
Sign in to follow this  
thecheeselover

Gui: in percents or in pixels?

This topic is 2486 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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,
Thecheeselover

Share this post


Link to post
Share on other sites
Advertisement
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
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!