- Home /
The question is answered, right answer was accepted
2D Unity game doesn't work with different resolutions
My game works normally only on editor resolution. If I change resolution half image goes out of screen. How to fix this? Why unity doesn't scale automatically to resolution what I choose. If you don't understand my problem I can take screenshots
I would suspect this has to do with how you are drawing, in particular what coordinates/transforms you are using for that. Rather than screen-shots, I'd like to see a snippet or two of that drawing code.
Answer by MakinStuffLookGood · Jan 20, 2015 at 05:41 PM
Unity does adjust to variable resolutions, but it's the height that is fixed. You want the width to remain fixed.
You can account for this by changing the orthographic size of your camera when the game starts:
float defaultSize = 1.6f;
void Start ()
{
camera.orthographicSize = defaultSize/ camera.aspect * camera.orthographicSize;
}
This assumes you designed your game for a 16:10 aspect ratio (change the "defaultSize" to whatever you designed the game at original , 16/9, 4/3, etc).
Keep in mind this will make more of the grass and sky visible, because the height will grow to allow for more visible width on a narrower aspect ratio.