Disable screen rotation in 2017

I’ve tried about 10 ways of disabling screen rotation based on previous answers and forum posts, but nothing works on Android 7.0

I currently have this in my manifest…

<activity android:name="com.unity3d.player.UnityPlayerActivity" android:label="@string/app_name" android:screenOrientation="landscape" android:configChanges="keyboardHidden|orientation|screenSize">

But still the screen rotates. I want to lock it to landscape.

Any ideas?

Thanks

In Unity you would do that in PlayerSettings->Resolution and Presentation.
Please let us know if there are any problems with that.

And which exact option in Resolution and Presentation would that be?
Setting it to Landscape Left does not lock the rotation on Android 7

Setting the “Default Orientation” to anything but “Auto Rotation” should work.
“Auto Rotation” + checking only a single box in the list of “Allowed Orientations for Auto Rotation” should also work.

Worked for me on the Google Pixel (Unity version is roughly current 2017.1 beta). If it doesn’t work then please report a bug so that our QA can have a look.

I’m using Unity 5.6.0p2, is that allowed orientations feature new in Unity 2017 only?
I don’t see it in 5.6.0p2.

it’s there in 5.5 so i guess it’s there too in 5.6 :slight_smile:

Ok I see now, if I set to Auto Rotation, it appears. Dumb UX on Unity’s part to be honest. You’d think if you select Landscape, it will force landscape.

That should work. As I said earlier you basically have two options to achieve this.

In Unity2017.1 I only see a dropdown menu and I can select only 1 option. How can I select both Landscape options?
Thanks!

Choose “Auto Rotation”, then “Allowed Orientations for Auto Rotation” will appear. Select both “Landscape Right” and “Landscape Left” checkboxes there.

2 Likes

Necroing this because my issue is similar, I want to ENABLE autorotation, but for the sake of me it doesn’t work.

I have Default orientation set as “Auto Rotation” and checked both landscape, but it does not rotate…

I’m on URP, is this overriden by something or I don’t know ? What’s going on ?

Which Unity version do you use? On which device have you tried this? Have you tried on multiple devices? Try a new empty project, maybe you have a custom manifest in your project or some plugins modify the behavior.

2020.1.24 (will try on 25 as it released, I know it’s alpha)
OnePlus 6 with OxygenOS 10.3.1 / Android 10
Only have one device, but I sent the game to a friend and he couldn’t aswell
I never touched anything in the manifest (I’m never doing mobile, wanted to try and experiment a bit) and have no plugins on the project.

Is URP, new input system or some Unity package known to introduce this behaviour ? If not, is there any other settings than the ones I posted above in the PlayerSettings ?

Doesn’t work on .25 either

I am not aware of any packages that would introduce this behavior. The only things that come to my mind are:

  1. Maybe you are setting a fixed orientation in your scripts? For example setting Screen.orientation to landscape right in the script would overwrite the autorotation setting in the editor and it wouldn’t rotate anymore.
  2. Maybe the autorotation is disabled in the Android OS settings on the device? That setting was not preventing rotation changes before, but I’ve heard recently, that on some Samsung devices with Android 10 disabling OS autorotation would prevent Unity to autorotate as well. Maybe that is happening on your device as well?
  1. Nope, not touching anything in that. I even tried to manually allow Screen.autorotateToLandscapeLeft/Right to true in script, but it doesn’t do anything either.

  2. I indeed have a button to toggle autorotation, but it is set to true, and other apps are rotating normally

Well, the easiest thing to try is to create a new empty project, set autorotation to the same values as in another project and check if it autorotates or not. If it does - then there must be something with the configuration of the project. If it does not rotate even with an empty project - please report a bug.

But this is what I did, I created and built this projet within the same day (basic flappy bird-like) just to experiment. I’ll try with default package, and with the ones I have and report

Update :

On a default project (URP template), without touching anything else than unchecking both Portrait in AutoRotation, it does rotate on my phone.

I though about what could cause the issue, because I had a similar thing happening for desktop. Some datas from PlayerPrefs regarding screen position / size where saved in PlayerPrefs and set back without any code from my side.

I may (I don’t remember) have built the app without autorotation or something, could it have saved that data and fetch that instead of what I now set in the PlayerSettings ? If so, how could I reset that ? (tried uninstalling the app, clearing data AND cache, but still no rotation).

In the meantime, I’ll try to update the packages to match and see if it stop the rotation

New update, found the problem.

Installing the new input system does prevent the rotation. I’ll try to post there to get a solution

1 Like