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.
You are not overwriting the android settings. You set the value also seen in player settings - android - resolution.
Could you restate your issue?
I do not understand what the issue is right now
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.
Is the setting in your phone to rotate the screen enabled?
Maybe the Screen.orientation only prints the current orientation?
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.
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
I have the same problem in Unity 2022.1.9f1c1。
I have the same problem in Unity 2020.3.37f1-39f1.
(Unity 2020.3.36f1 no problem.)
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).
The value of screenOrientation in AndroidManifest was set to “11”(userLandscape), so it seems that enabling “Settings > Display > Auto-rotate screen” rotates the screen.
Same issue after upgrading old games to Unity 2021.3.11f. Workaround: in AndroidManifest, in main Activity add android:screenOrientation=“landscape”
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.
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.
I found this issue tracker.
It says the issue was resolved, stating what we’ve already said in this thread about screen rotation being locked in the device.
Hello.
It had been requested several times to follow the orientation lock settings on the device and it was applied by this ticket (Unity Issue Tracker - [Android] Screen can be rotated when native 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. (Unity - Manual: Android Player settings)
Please refer to the following link for the applicable version.
So what about previous versions, like 2022.3? Should we override the AndroidManifest.xml file?
