How to detect if this device has a "home button" swipe gesture area?

I’ve got an app that involves a lot of tapping, and testers with an iPhone X (with no physical home button — ones where you just swipe up from the bottom) are finding that they are inadvertently invoking the “home” function while tapping in that part of the screen.

So I’d like to detect when we are on this sort of device, and just shorten my game display to avoid the bottom of the screen. But how do I do that?

How can I know when I’m running on a device with a home gesture instead of a hardware button?

There probably an easier way, but you can check if the safe areas are not at the screen borders.

1 Like

Thank you for the suggestion, but it turns out this doesn’t work. The entire screen is reportedly safe. (Screen.cutouts is empty too.)

Any other ideas?

Which Unity version? I don’t know about cutouts but safe areas definitely works, we use safeAreas extensively to place UI elements in our games and it is definitely working.

Try this one:

if (Screen.safeArea.y > 1)
    // no physical home button, do stuff to avoid onscreen home button

I’m using 2019.4.33f1. Screen.safeArea reports as [0, 0, 1170, 2532] on this device (which also reports a resolution of 1170x2532).