Safe Area Problems!

Hi,

I have an Android portrait app, which is designed to “stretch” the canvas to the full screen, scaling everything with it. Even if it becomes a little distorted and out of aspect.

To do this I have an Orthagraphc Camera and the Render Mode of my Canvas is World Space.

I then have this code attached to the Canvas:

Vector3 screenSize = Camera.main.ViewportToWorldPoint(Vector3.up + Vector3.right);
screenSize *= 02;
float sizeY = screenSize.y / rt.rect.height;
float sizeX = screenSize.x / rt.rect.width;
rt.localScale = new Vector3(sizeX, sizeY, 1);```

This has been working fine for the past 18 months or so...

I now want to release my apps on IOS, and need to make everything fit to the SafeArea for the iPhone X etc.

Every SafeArea script I have tried does absolutely nothing...

Is there anything I can do with my current set-up to get one of these SafeArea scripts working? 

Can I modify my little bit of code above to set the Canvas size to the SafeArea instead of the camera size?

Many thanks for any advice!

MIke.

If you’re using Screen.safeArea, you can get the same screenSize point by using Camera.main.ScreenToWorldPoint( Screen.safeArea.max ).

Since the safe area is probably not centered on the screen, you will also want to shift the transform to be placed in the center of the safeArea rectangle. There’s several ways to do this – one way could be to also convert Screen.safeArea.center to world space and place the transform there.