Camera and Game View Different From Build
I have been working on a 2D game for some time now, and I set up the scene to fit into the "Camera View" and viewport that I first had when starting my new project. I opened up Unity this time, and I've noticed that my "Camera View" and viewport are VERY WIDE, even though I don't remember changing anything. Fortunately, when I "Build and Run" my game (Android) it still reflects as though it had it's original camera size, thus showing a full-screen background sprite. However, I would like my "Camera Preview" and "Game View" to reflect my original camera size, like my actual game build does.
Originally I thought changing the "Viewport Width" manually to a size similar to what it used to be would work, but that makes it so that the built version is clipped on one side, so I need to stick to a 1:1 ratio. Please help me get my original camera and camera preview back~
EDIT: Okay, so it seems that the "Camera Preview" and what appears to be the viewport box are actually just resized according to the size of my scene view window/panel in the editor. That makes absolutely no sense to me.....
So, NEW question: Is there a way to preview what my game will look like on devices? I thought what you put inside the "Camera View" was what got stretched full-screen on the device. Now that I know that's not the case, how can I know what is going to be shown? How will I know where to put things?
Answer by KdRWaylander · Mar 10, 2016 at 09:46 AM
Hi, about your new question:
Start by setting the resolution you want for your app in the Build Settings (File > Build Settings > Player Settings)
In the Game view/tab, click on the resolution button which generally displays "free aspect", just underneath the name of the tab (upper left part of the Game view) ... and set the Game view to your wanted resolution.
In the player settings the only thing that I can change is whether it is Landscape or Portrait. In the Game view there are several "Landscape" resolutions--is this how my game will look on devices with the respective resolution?
If that's the case how can I, let's say, make sure a monster shows up a quarter screen length from the side of their screen no matter which device they are using?
You can change the resolution, when in the player settings, in the Standalone tab.
Forcing the resolution to a certain ratio will indeed show you how it will be displayed at the end.
If you're using a Canvas, you can set the Canvas Scaler component to "Scale with Screen Size" so it'll keep the same aspect whatever the resolution is (but you'll see the pixels if you switch to a wider resolution)
You should be able to get the screen height and width, use them to place your enemies accurately (like x = 0.25 * screen.width)
Your answer
Follow this Question
Related Questions
HOW TO - Camera Viewport Rotate OR Mask OR Transparent? 0 Answers
Layered/slanted camera view 0 Answers
Converting World coordinates to Viewport in split screen 1 Answer
Viewport affecting custom projection matrix 0 Answers
Game window is blurry?! 0 Answers