In my Unity game I made changed my Pixel Per Unit value to 243 since the height of a Portrait game for iPhone X is 2436. The game looks great and the asset sizes look just right on the iPhone X simulator. But when I change to iPhone 7 Plus I get considerable space on the sides and it gets worse when I change to the iPad. How can I make my game have the same width gaps for iPhone 7 Plus and iPhone X without making assets look stretched horizontally or vertically?


The images below give an idea of my game on both 1080x1920 (for iPhone 7 Plus) and 1125x2436 (for iPhone X). It's not a match3 game. All the game objects below are static and have colliders. The gaps between are quite significant for other dynamic objects to move between. Reducing the gaps significantly would alter the movement of the dynamic objects and their sizes too, making the ratio in object sizes look wrong. I haven't started worked on scores or menus yet, so I haven't added a UI canvas yet.

enter image description here

enter image description here

  • \$\begingroup\$ One way is to letterbox/pillarbox the game. I did that for my Unity game, Cognizer (free on iOS and Android). \$\endgroup\$ – Almo Sep 27 '17 at 21:58
  • \$\begingroup\$ @Almo, doesn't letterboxing creating black borders at both sides? that wouldn't work for me. I need to show the equal amount of screen on both sides with black borders. \$\endgroup\$ – Containment Sep 28 '17 at 8:13
  • 1
    \$\begingroup\$ Now that I can see what you're trying to do, it looks like you just need to adjust the orthographic size of your camera using one of the techniques listed here: How do you handle aspect ratio differences with Unity 2D? Don't forget to search for similar questions to see if the materials you need are already available! \$\endgroup\$ – DMGregory Sep 28 '17 at 16:12
  • 1
    \$\begingroup\$ @DMGregory I tested the solution you linked extensively, but it doesn't solve my issue. I guess that might be why the answer wasn't accepted. Game objects at the far ends are taken care of, but the ones between don't seem to preserve the gaps between. Here are some sample images of the results from Full HD Screenshot and iPhoneX Screenshot \$\endgroup\$ – Containment Sep 28 '17 at 20:24
  • 2
    \$\begingroup\$ @Almo I've been battling with a similar issue. How does the letterbox approach work? \$\endgroup\$ – SuperHyperMegaSomething Sep 28 '17 at 21:09

This Script writes on your Camera Setup and runs it. It used for Portrait mode only. Count Width of Object it is our WorldWidth.

Then Follow this Script:

    public float worldWidth = mainObjectWidth;
    void Awake()
        float x = worldWidth;
        float y = x * Screen.height / Screen.width;
        Camera.main.orthographicSize = y * 0.5f;

It will work for sure. :)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.