Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We've updated our Terms of Service. Please read our blog post from Unity CTO and Co-Founder Joachim Ante here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Where are Screen.safeArea's defined?

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

  1. lumoconnor

    lumoconnor

    Joined:
    Jan 17, 2016
    Posts:
    11
    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,260
    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:
    11
    Excellent. Thanks for your help!