- Home /
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.
Did you find the Screen class? It has variables for the screen width and height
Answer by Owen-Reynolds · Jun 21, 2013 at 04:02 PM
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.)
That's great, thank you. I now at least have an idea where to begin looking. Thanks for the quick response.
Your answer
Follow this Question
Related Questions
Does Resolution of images used in game affect performance on Low End Devices? 0 Answers
How to get native resolution of mobile devices 0 Answers
unity5.4 and NGUI3.9.9 when call Screen.SetResolution game window black 1 Answer
How to adjust positions of the sprites to different screen factors? 2 Answers
How to Adjust Size of objects/Camera's size for different resolutions 1 Answer