- Home /
2D ortho camera screen rotation
I know there are plenty of similar questions, but most seem to be related to pixel-perfect. I'm not looking for that. I'm not sure exactly what to call what I'm looking for, and that's probably why I can't find any existing answers. So here are some pictures to explain it.
I have a 2048x2048 background that I created in Photoshop, and I made some red boxes over it as guides. The red boxes are the correct aspect ratio for iPhone 5 in portrait and landscape.
I want the red boxes to match the viewport in Unity, when the device rotates:
By default, Unity wants to keep the viewable height the same. Here is how it currently looks in game view:
I don't just want to support iPhone 5 or these 2 exact resolutions, of course. Basically I just want the camera to always maintain the same center point, but instead of staying a fixed height like it does now, I want it to just rotate around that point as needed -- sorry, I'm not sure what this is called. I'm using an ortho camera in a 2D project.
$$anonymous$$ight still be nice to hear an answer that explains the math (or just a camera option?), but for now I found something that seems to work well. I just manually adjust the camera size and Y position so that it looks good. Then I checked the $$anonymous$$ and max aspect ratio that I think will cover all devices (in landscape mode) and they all looked acceptable. I put camera settings back to portrait values, and tested all portrait aspect ratios, also looks acceptable. So in my case I guess I'll just have 2 hard-coded settings, one for landscape (screen width > height) and one for portrait. Every size has a slightly different viewable area, but my GUI will handle that and the game area will just stay inside the smallest intersect of all.
Your answer
![](https://koobas.hobune.stream/wayback/20220613162444im_/https://answers.unity.com/themes/thub/images/avi.jpg)