Is there a correct way to set up a project to make it more universal.

Hi, Rob here.

Is there a way to set a project in a way to size and place all objects, GUI’s and such in a way that they are based on the resolution of the screen. For instance making games in XNA I was able to call getScreenWidth and then scale an object to always be in a certain place at a certain size based on that value. I have not been able to find anything like that so far in Unity and am unsure if you need to readjust valued depending on what you are aiming the build towards.

Sorry if this is a little generic, but I figured that if any pros stumble across this and have any information how this would be approached in industry, an insight would be much appreciated.

Thanks in advance.

In Unity, most GUI elements can be placed in screen percents, which solves the screen size problem. They can also be placed in pixels, but that’s for if you have to show something pixel-perfect, which you never do.

For the few things which require pixels (the GUI-dot draw commands) the idea is to think in screen width percents and convert that to pixels just before the draw (using functions from that Screen class.) Lots of stuff here on how to do that.

The only thing to watch out for is different AspectRatios (also plenty of discussion here about that.)