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

Bug Android phones. Screen.safeArea not works correctly

Discussion in 'Android' started by smirnov_m, Aug 30, 2022.

  1. smirnov_m

    smirnov_m

    Joined:
    May 26, 2021
    Posts:
    3
    Safearea works correctly in Unity 2019.4.29 but after switch to 2021.3.7 (or 2021.3.8, 2021.3.4) safearea stopped working only on android.
    ios devices and device simulator work correctly with the same code.

    On all our android devices:
    1. "safeArea.x" and "safeArea.y" is zero
    2. "safeArea.width" is equal to Screen.width

    Info:
    • only landscape orientation
    • tried android api 30, and 31
    • tried different andoird OS versions (10,12) and different devices
     
  2. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    4,456
    If it did work in an older version make a bug report.
     
  3. smirnov_m

    smirnov_m

    Joined:
    May 26, 2021
    Posts:
    3
    Fixed it, If you have the same problem you should check your android manifest and compare with Unity generated manifest

    What we did:
    1. Added the "android:theme"
    2. Changed "screenOrientation" to actual
    3. In "UnityPlayerNativeActivity -> android:configChanges" we added layoutDirection and density
     
  4. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    4,456
    Interesting, could you make a bug report for this?