- Home /
Fitting camera in different resolutions.
I built my 2d game to xcode and ran it on the ios simulator for 3.5 inch (iphone 4s). The camera is cut off. How do I make it so that the camera would not cut off in smaller resolutions? It is ok if the contents seem squished or stretched.
Answer by maccabbe · Mar 28, 2015 at 05:08 AM
Use Camera.aspect, for instance if we wanted a 4:3 ratio use
Camera.main.aspect=4f/3f;
How can the script recognise that the device used is an iphone 4s? Is there an if statement for that? I don't want the aspect to change because the camera would be smaller and would cut off parts of the screen. Is there a way to squish in the content in the camera?
Yes, you can use the preprocessor directives that are platform dependent:
#if UNITY_IPHONE
// your code here
#endif
Or you can use this:
if(Application.platform == RuntimePlatform.IPhonePlayer)
{
// your code here
}
To know the aspect ratio, use Screen.width & Screen.height
Doesn't changing the aspect causes the screen to get cut off though? @sumeeton
Okay here's the thing. While designing the game you need to setup scenes such a way that it supports different aspect ratios you intend to. You can check this in the game view. Camera doesn't cut off the scene for a display. It'll display the actual content that can be displayed for the given aspect ratio of the screen. Now that you have already built the scenes, we can make changes to the camera to avoid reconstructing the scenes. Select the camera and adjust the Field of View property and test it out in the Game View with the desired aspect ratio.
Changing aspect will definitely affect the contents rendered. It is up to you to how to use the aspect property.
Your answer
![](https://koobas.hobune.stream/wayback/20220613191446im_/https://answers.unity.com/themes/thub/images/avi.jpg)