Search Unity

Bug ScreenOrientation.AutoRotation not working on Unity2021.3.9f1 Android

Discussion in 'Editor & General Support' started by ttt1088, Sep 9, 2022.

  1. ttt1088

    ttt1088

    Joined:
    Nov 7, 2019
    Posts:
    5
    Whether set auto rotation in project setting or set
    Screen.orientation = ScreenOrientation.AutoRotation,it always be landscape on phone.
    I must check the auto rotation setting in my phone then the game can rotate as usual.
    The auto rotation work as expected on Unity2021.3.5f1 and I didn't see any changelog about this in recently release notes.
    So I think it must be a new problem.
     
    NelsonChristensen likes this.
  2. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,063
    You are not overwriting the android settings. You set the value also seen in player settings - android - resolution.
     
  3. ttt1088

    ttt1088

    Joined:
    Nov 7, 2019
    Posts:
    5

    I'm sure my resolution setting is right.It just not working on Unity2021.3.9f1.

    1.png
     
  4. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,063
    Could you restate your issue?
    I do not understand what the issue is right now
     
  5. ttt1088

    ttt1088

    Joined:
    Nov 7, 2019
    Posts:
    5
    The issue is when I rotate my phone to the other side,the game should rotate from landscape right to landscape left automaticly,but in the latest unity version,the game always keep landscape right no matter how I rotate the phone.I print the Screen.orientation and value is ScreenOrientation.Landscape.But I'm sure it should be set to ScreenOrientation.AutoRotation.
     
  6. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,063
    Is the setting in your phone to rotate the screen enabled?

    Maybe the Screen.orientation only prints the current orientation?
     
  7. ttt1088

    ttt1088

    Joined:
    Nov 7, 2019
    Posts:
    5
    The setting in my phone is disable.
    But my question is the old version unity can rotate the screen even if I disable the setting in my phone,and so do other game made by unity.
     
  8. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,063
    You can submit a bug report in that case. I am guessing a new version wanted to standardize things (like other apps only doing this with the settings turned on), but we'll see.
    Let me know if you get a response
     
  9. EdwardAndy

    EdwardAndy

    Joined:
    Jul 26, 2020
    Posts:
    24
    I have the same problem in Unity 2022.1.9f1c1。
     
  10. KenjiSaitoh

    KenjiSaitoh

    Joined:
    Apr 21, 2015
    Posts:
    2
    I have the same problem in Unity 2020.3.37f1-39f1.
    (Unity 2020.3.36f1 no problem.)
     
  11. makkysan

    makkysan

    Joined:
    Sep 20, 2018
    Posts:
    3
    I am reproducing this on my environment with Unity2021.3.9.
    I checked the generated apk and it seems that the value of screenOrientation in AndroidManifest is 11 (fullSensor) in Unity2021.3.9.
    I am wondering why this value would change since the app I created with Unity 2018.4.34 has the same setting of 6 (sensorLandscape).
     
  12. KenjiSaitoh

    KenjiSaitoh

    Joined:
    Apr 21, 2015
    Posts:
    2
    The value of screenOrientation in AndroidManifest was set to "11"(userLandscape), so it seems that enabling "Settings > Display > Auto-rotate screen" rotates the screen.
     
  13. Rafal_Marchewka

    Rafal_Marchewka

    Joined:
    Apr 1, 2021
    Posts:
    5
    Same issue after upgrading old games to Unity 2021.3.11f. Workaround: in AndroidManifest, in main Activity add android:screenOrientation="landscape"
     
  14. mori_masaki

    mori_masaki

    Joined:
    Jul 6, 2022
    Posts:
    2
    We have confirmed that the same issue is occurring in Unity 2020.3.42f.
    In my environment, I was able to temporarily resolve the issue by using the OnPostGenerateGradleAndroidProject method to rewrite the screenOrientation value in the manifest before the Gradle build.
    I hope the problem will be resolved in some version of Unity.
     
    ritro_hype likes this.
  15. gabagpereira

    gabagpereira

    Joined:
    Jan 21, 2019
    Posts:
    24
    I'm also facing this issue.

    Yes, I do have auto-rotation disabled on my phone, but I can still play other games either in Landscape Left or Landscape Right Orientations. However, this does not apply for my Unity game. I can only play in one Landscape orientation (with auto-rotation enabled for both Landscape orientations in the Player Settings), unless I enable auto-rotation directly on the phone.
     
  16. mori_masaki

    mori_masaki

    Joined:
    Jul 6, 2022
    Posts:
    2
  17. gabagpereira

    gabagpereira

    Joined:
    Jan 21, 2019
    Posts:
    24
  18. VeryHappyYoung

    VeryHappyYoung

    Unity Technologies

    Joined:
    Nov 19, 2018
    Posts:
    4
    Hello.
    It had been requested several times to follow the orientation lock settings on the device and it was applied by this ticket (https://issuetracker.unity3d.com/is...ative-screen-rotation-on-device-is-turned-off).

    However, after the fix, I could see a lot of requests to ignore the orientation lock setting of the device.
    So now, we added 'Auto Rotation Behavior (User or Sensor)'.
    You will be able to see 'Auto Rotation Behavior' option when Default orientation is set to Auto rotation. (https://docs.unity3d.com/2023.3/Documentation/Manual/class-PlayerSettingsAndroid.html)

    Please refer to the following link for the applicable version.
    https://issuetracker.unity3d.com/is...ntation-when-the-custom-main-manifest-is-used
     
    coldlogic likes this.
  19. Epiplon

    Epiplon

    Joined:
    Jun 17, 2013
    Posts:
    52
    So what about previous versions, like 2022.3? Should we override the AndroidManifest.xml file?
     
    Last edited: Nov 20, 2023
    adamfuj likes this.