6

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?

UPDATE

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

Containment
  • 173
  • 1
  • 10
  • One way is to letterbox/pillarbox the game. I did that for my Unity game, Cognizer (free on iOS and Android). – Almo Sep 27 '17 at 21:58
  • @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. – Containment Sep 28 '17 at 08:13
  • @DMGregory I just confirmed from Apple iPhoneX Human Interface Guidelines that the dimensions for iPhoneX is 1125x2436 this gives an aspect ratio of 18.5:9. This is longer and thinner than the iPhone 7 Plus, that's why I'm having an issue. – Containment Sep 28 '17 at 13:59
  • Ah, my apologies, the site I'd consulted had the wrong numbers on it. We'll still need to see your scene setup and the symptoms you're trying to correct in order to tell you what to change. There's lots of considerations when changing aspect ratios, so the same steps won't be right for every game. – DMGregory Sep 28 '17 at 14:04
  • Yup, that's the black bar setup. I much prefer it. – Almo Sep 28 '17 at 14:10
  • @DMGregory I am using the default orthogonal Camera Settings for my scene. At first I was using a PPU of 192 (for all images) then I realized that it truncated some of my game objects (static game objects) closer to the screen edges for the iPhone X. So I changed to 243 and this gave a lot of space at the edges (definitely not what I want for the iPhone 7 Plus). I would like my game to have consistent gaps at both the left and right of the screen for both devices without making the game objects looking stretched. – Containment Sep 28 '17 at 14:27
  • @DMGregory I just updated the question. Please let me know if there's anything else you'd like to know. – Containment Sep 28 '17 at 15:40
  • 1
    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! – DMGregory Sep 28 '17 at 16:12
  • 1
    @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 – Containment Sep 28 '17 at 20:24
  • 2
    @Almo I've been battling with a similar issue. How does the letterbox approach work? – SuperHyperMegaSomething Sep 28 '17 at 21:09
  • @SuperHyperMegaSomething See this question and answer I just put up. :) https://gamedev.stackexchange.com/questions/148995/how-can-i-get-unity-to-do-letterbox-pillarbox-to-maintain-aspect-ratio – Almo Sep 30 '17 at 10:35

1 Answers1

1

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. :)