- Home /
Make an Orthographic Camera FIT in the screen, not FILL it.
Hello guys,
I've developed an Android/iOS application. When I run it in a equal/similar screen resolution ratio it sees okay, the problem comes with other resolutions.
As the GUI must be located attached to the screen coordinates, I developed all my GUI followed by this lines:
Vector2 ratio = new Vector2(Screen.width / ancho, Screen.height / alto);
Matrix4x4 matrizGUI= Matrix4x4.identity;
matrizGUI.SetTRS(new Vector3(1, 1, 1), Quaternion.identity, new Vector3(ratio.x, ratio.y, 1));
GUI.matrix = matrizGUI;
These lines make the GUI adjust to the screen resolution, and it does it properly with resolutions with same ratio.
The thing is that I must maintain the ratio I chose. I need to make my ortographic camera (or whatever) maintain this ratio when the devide ratio is different, to avoid the scene backgrounds look weird and the GUI lose their reference to them.
I need to keep this ratio, ¿is there a way to avoid the screen filling?
I hope I've explained right my problem and you could help me.
Thank you very much in advance,
Alex.
I think not filling the screen and forcing one aspect ratio makes your game less appealing. I mean why whould you discri$$anonymous$$ate players on what display they have? ^_^ The first reaction would be: "why's the game not filling my screen?". I'd recommend setting up a GUI system which positions itself properly regardless of aspect ratio.. that's the only way to go in my opinion. Also if you have an orto camera, you can try to adjust the Size property based on the aspect ratio, but that's probably not a solution. If you have perspective camera, you definitely can adjust the FOV to the ratio.
I'm grateful for your message, z_murc. The thing is that $$anonymous$$e is not a 3D game. I have all sort of images that must keep their ratio to keep them clear-cut. So... as far as I can see the ratio must keep my background image ratio even if its not the most elegant solution.
Your answer
![](https://koobas.hobune.stream/wayback/20220613091101im_/https://answers.unity.com/themes/thub/images/avi.jpg)