Adaptive ui for different screen aspects

Hi!
Can you suggest how I can dynamically adapt the ui for different cases. For example, the design resolution of my game is 1080x1920. In the settings, I check the box next to FitWidth. The game will look good when the aspect ratio of the screen is such that the width is smaller than the height (pic 1).

pic 1

However, if you try to run the iPad resolution 12, then the ui will look incorrect (pic 2).

pic 2

To make it look right on the iPad, you need to check FitHeight. (pic 3).

pic 3

But then it will look bad on screens with a ratio where the height is less than the width (pic 4).

pic 4

I plan to make the game look correct on different resolutions, how can I achieve this?

Project source. CC 3.7.1
NewProject_456.zip (4.4 MB)

You are correct about fitwidth & fitheight.
So to achieve for all cases set fitWidth/fitheight on game launch via code.

hi! thanks for your reply
how can I set fitwidth & fitheight via code?

You can search forum for the same.

view.setDesignResolutionSize(designResolutionWidth, designResolutionHeight,  ResolutionPolicy.FIXED_WIDTH);

Some useful apis

var deviceResolution = view.getVisibleSizeInPixel();
var designResolution = view.getDesignResolutionSize();
1 Like