My problem is simple. When I change aspect ratio from 4:3 (iPad resolution) to 16:9 (iPhone resolution), my camera keeps the height fixed and adds visible spaces to left and right and visa-versa (if you change from 16:9 to 4:3, camera keeps the height fixed and removes spaces from left and right).
What I want from my camera to do is simply keeping width fixed and removing or adding spaces to top and down. Let me explain what I want with an illustration clearly:
Unity does the first one as I explained. What I want is the second one. (Please note I dont want to stretch or expand my sprites) So I want my game look with aspect ratios changes as in the second one in iPad and iPhones.
Aspect ratios are a big challenge for 2D game design. It’s a little easier for 3D games, where scaling interfaces doesn’t need to be as significant for level design. In 2D games what is displayed on the screen can be more significantly influenced by the aspect ratio, or changes in resolution. I would point to the changes between the SNES and GBA as an example. Quite a few ports of SNES games to the GBA suffered from the fact that the GBA actually had a lower resolution compared to the SNES. (despite being more powerful in other areas) If you are going for more of a retro pixel-art style in your game, it just compounds the issue. (with the various scaling problems that crop up)
I personally recommend letterboxing for this issue. Some people don’t like black bars, but I consider maintaining consistency of aspect ratio to be more important. In Unity you can use the Viewport object to adjust drawing, so that your rendered area is more tightly constrained, saving on performance. You can use the GUI drawing to create letterboxing bars, and either go with straight black, or add some manner of texture or decoration.
The needed calculations for adjusting the proportions is just some relatively simple math. The significant property that you would need to concern yourself with is the “Size” property for your primary orthographic camera. This property is what determines how many Unity Units a Sprite is rendered as. It needs to be adjusted based on the resolution you are rendering at, so that there is consistency for how your sprites are being rendered given the difference in aspect ratio.