Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Bug Wrong Screen.safeArea in Unity Editor for most devices

Discussion in 'Editor & General Support' started by twell59, Aug 28, 2023.

  1. twell59

    twell59

    Joined:
    Feb 6, 2016
    Posts:
    25
    1. For iPhones the Screen.safeArea returns the correct values.
    2. But for most other devices, like Samsung Galaxy S10+, the position of safeArea is x: 0 and y: 0, which is not correct.


    The code I'm using is this:
    Code (CSharp):
    1.  
    2. Rect safeArea = Screen.safeArea;
    3.  
    4. string safeAreaInfo = "Safe Area:\n";
    5. safeAreaInfo += "x: " + safeArea.x + ", ";
    6. safeAreaInfo += "y: " + safeArea.y + ", ";
    7. safeAreaInfo += "width: " + safeArea.width + ", ";
    8. safeAreaInfo += "height: " + safeArea.height + "\n";
    9. safeAreaInfo += "xMax: " + safeArea.xMax + ", ";
    10. safeAreaInfo += "yMax: " + safeArea.yMax + ", ";
    11. safeAreaInfo += "center: " + safeArea.center + ", ";
    12. safeAreaInfo += "position: " + safeArea.position + ", ";
    13. safeAreaInfo += "max: " + safeArea.max + ", ";
    14. safeAreaInfo += "min: " + safeArea.min;
    15.  
    16. Debug.Log(safeAreaInfo);
    17.  
    The incorrect output is this:
    x: 0, y: 0,
    width: 1440, height: 2898
    xMax: 1440, yMax: 2898
    center: (720.00, 1449.00)
    position: (0.00, 0.00) // This is wrong!
    max: (1440.00, 2898.00)
    min: (0.00, 0.00)
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    6,003
    Are you reporting any bugs for all these posts?
     
  3. twell59

    twell59

    Joined:
    Feb 6, 2016
    Posts:
    25
    No.

    Should I report each issue in [Help > Report a Bug...]?
     
  4. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    6,003
    Yes. Bugs won't get actioned unless an official report is made. The forums can just be used to inform others and discuss them.