Something that you can do to then make it easier for yourself is switch the numbers in Derek’s code snippet to be 1920 for the width, and 1080 for the height. This way your always working in a virtual space of 1920x1080, but it will map to whatever size the users window is and maintain the proper sizing ratios. Since you’re developing in 1920x1080 you have a better feel for how things should be in that space and can make better guesses when positioning and sizing things at first.
function getUniversalWidth( number )
return ( number / 1920) * ScrW()
function getUniversalHeight( number )
return ( number / 1080) * ScrH()
Be wary though, if you start using that sort of system you ALWAYS need to use it from then on, otherwise things can get really messy (Don’t use ScrW/ScrH anymore if you use getUniversalWidth/Height, just treat 1920 as max width, and 1080 as max height). While using ScrW/ScrH might not actually cause you any problems, it’s easy to accidentally use it the wrong way and then not notice something screwed up on a different resolution until later on, it’s just a safety precaution really. Make sure you also use the universal width/height for the positioning as well as sizing too!
draw.RoundedBox( 0, getUniversalWidth(1920 / 2), getUniversalHeight(1080 / 2), getUniversalWidth(512), getUniversalHeight(512), hudcolors.background_white )
No matter what though, you’re going to start hating whatever method of sizing and aligning UI you end up using. There is no agreed upon “right” way of sizing UI for multiple resolutions, and it all depends on the type of game and what you’re using it for. Some games work better if you keep HUD elements a fixed size, no matter the resolution of the window, some games prefer to have it always be a fixed ratio/percentage of the window, some games do a sort of hybrid of both. For instance, EVE Online has fixed UI sizing, but you can increase the scale of it from 80-120% (roughly those numbers) since the fixed size might be too small or large for your monitor.