Search Unity

Where are Screen.safeArea's defined?

Discussion in 'Scripting' started by lumoconnor, Jan 11, 2019.

  1. lumoconnor

    lumoconnor

    Joined:
    Jan 17, 2016
    Posts:
    20
    Hi all,

    I'm using Screen.safeArea to adjust the UI in my game so that it fits nicely within the screen on any device (including iPhone X with its notch and curved corners).

    What I'm wondering is where the safeArea of a device is defined? Is Unity looking it up on each device, or is it hard coded in Unity for a number of devices?

    The reason I ask is that I want to make sure that my code will work with all future devices.

    Thanks!
     
  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    5,618
    It's not hardcoded. iOS and Android P (I think?) have APIs that return the device's safe areas. Unity uses those APIs.
     
  3. lumoconnor

    lumoconnor

    Joined:
    Jan 17, 2016
    Posts:
    20
    Excellent. Thanks for your help!