- Home /
The question is answered, right answer was accepted
Unity2D - Camera in exported game is zoomed out compared to unity game preview HELP PLEASE!
Ok so I'm making a 2d game, when designing the UI of the main menu or the HUD in levels everything looks fine in the game preview but when I test the game on an actual device the camera is zoomed out and the HUD in levels are out of place. Please help me with my problem I'm new to Unity. If this question is answered somewhere else please redirect me to it. I will accept any help I can get. Here are some screenshots of what happens:
How it looks in Unity:
How it looks on the exported game:
That blue space around is part of the screenshot. I set the background color of the MainCamera to blue. I shouldn't be seeing it since i focused my camera on the UI in screenshot one.
Answer by _Game_Dev_Dude_ · Nov 17, 2015 at 05:22 PM
There is a little box underneath your game view that says "Free Aspect". This is your problem I would wager. This needs to be changed to the target size of your deployed build. So for example, you can make a new aspect of 16:9 and then set your game view to this and it will look how it will look on a 16:9 display.
Please explain more. How exactly do i go about doing that. Does changing the aspect in the game preview window automatically affect the screen size of the target build? Thanks.
Basically that button allows you to preview what your game will look like on different resolutions. It does NOT effect build settings, target resolution, or anything like that it is strictly a tool you can use to preview how your game will look.
So if you know what you are deploying to, for example a 16:9 phone, you can change it to 16:9 and do all your layout work from there.
When you click the Free Aspect button, a drop down should come up with the most common aspects. However there is a small plus sign at the bottom of the drop down that you can use to create a custom one. This can be either resolution (1920 x 1080, etc) or an aspect (9:16, 4:5, etc).
I think what is happening is right now your game window is so small that free aspect is causing it to be shaped based on a very low resolution. When this gets exported to a bigger screen it fills that space with the blue background. I would pull the game window out and let it be fullscreen and then set the resolution/aspect as I described above and then see how the game looks.
Answer by tanoshimi · Nov 18, 2015 at 10:15 AM
I'd also encourage you to learn about the canvas scaler component: https://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/resolution-and-device-independence
Follow this Question
Related Questions
flickering lines when zooming fov (both GUI and ortho cameras). 2 Answers
Moving camera around with GUI buttons 4 Answers
Is there a way to zoom GUI and scene at the same time? 0 Answers
camera zoom using gui button 2 Answers
Raycast misses after camera zoom 2 Answers