Search Unity

Question iPhone's safeArea incorrect?

Discussion in 'iOS and tvOS' started by GuirieSanchez, Dec 2, 2022.

  1. GuirieSanchez

    GuirieSanchez

    Joined:
    Oct 12, 2021
    Posts:
    452
    I marked in red the part that in theory should be covered as safeArea. I don't know why newer iPhone models (from X and above) have this empty space on the bottom, maybe it's intentional or maybe it's a bug on my editor, but it's making the canvas too small in my opinion.

    upload_2022-12-2_13-39-50.png

    If this were the intended safeArea, is there a way to modify it so I can use the bottom space?
     
    sisF likes this.
  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,796
    It's intentional because that is where the software home button lives on iOS.
     
    sisF and GuirieSanchez like this.
  3. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,796
  4. GuirieSanchez

    GuirieSanchez

    Joined:
    Oct 12, 2021
    Posts:
    452
    Thank you for replying. I have an iPhone myself and I was testing other apps, let me show you this one for example:

    upload_2022-12-2_14-11-29.png

    then the home button disappears after a second

    upload_2022-12-2_14-11-49.png

    As you see here, whereas in my case, the home button stays forever, I don't know why.

    Most importantly is that the safeArea seems to ignore the home button because it's going to disappear anyway, as seen here:

    upload_2022-12-2_14-17-24.png

    upload_2022-12-2_14-15-2.png
     
  5. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,796
    AFAIK (and things may have changed recently), the only valid use for a disappearing is if your game is a media app, and in that case, it instantly comes back the moment there is input. If you hide the home button for things that are not media apps I think it's grounds for apple to reject your app.

    https://docs.unity3d.com/ScriptReference/PlayerSettings.iOS-hideHomeButton.html

    In any case, in our case, we read the safe areas and then do a bunch of conversions, sanity checks and math to it to use in the game (which I think is a good idea, since some devices, especially on Android return bogus values, and Unity has been buggy in this area as well), but our UI is all custom, so I'm not sure if you can change the safe areas that are being fed to UIElements/Toolkit or UGUI.
     
  6. GuirieSanchez

    GuirieSanchez

    Joined:
    Oct 12, 2021
    Posts:
    452
    Thank you! I found it and enabled the option:
    upload_2022-12-2_14-50-31.png

    Regarding the safeArea, I assume we get that safeArea info from an iPhone, and then one should set the canvas height to normal if wanted. Maybe just by converting the anchor's Xs but keeping the original Ys; this way, it doesn't get affected by the safeArea's height. However, I don't know to apply this only for certain devices instead of for every device.
     
  7. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,796