- Home /
How to make Unity Player respect Android system settings
I am trying to get my Unity player to auto rotate based on the device. You can easily do this by setting the Screen Orientation to "Auto Rotate". This works fine, however, when the system settings of an android device is set to "Disable auto rotate", Unity continues to rotate the application.
In iOS, setting your device to not auto-rotate disables the unity rotation, as expected.
This is a major bug in the Unity player. I have been trying to find a work around and have been unable to do so.
How do I create an application, for android, that will auto rotate only if the device system settings allows for it?
Answer by jongallant · Nov 26, 2014 at 04:10 PM
This is a major bug in Unity. For those who are stumbling here trying to find a solution, a very awesome gentlemen posted a fix over here at github
https://github.com/hvs-clark/unity-android-rotation-lock
Hopefully Unity fixes this crazy bug soon, so we don't have to use workarounds like this in the future. From what I read, it is by design, which in my opinion is horrible design. https://github.com/hvs-clark/unity-android-rotation-lock
This plugin sets Portrait, which is incorrect for tablets, and is incorrect for Landscape-designed games. Landscape can also disappoint as on some devices it is messed up. The things are not black-and-white; doing a quick fix and supporting an entire range of devices are different things. The best thing you can really do is submit a bug, not make public judgements about the design.
This is the workaround. I submitted a bug report already, which will most likely be ignored, as this is by design. The example provided is just an example, a proof of concept. You can make it work the way you want. Bottom line is, this is a valid work around, so use it if you encounter this bug.
This workaround is a close equivalent to just setting "Portrait" in the player settings, which I recommend doing if you care about the orientation. And thank you for submitting the bug!
Answer by Yury-Habets · Nov 26, 2014 at 08:13 AM
Please submit a bug report if you consider this is unintended behavior.
Yes, I have already submitted a bug. I am currently looking for a workaround for this problem. Any suggestions as to what I could do would be greatly appreciated.
Yes - write a plugin or use AndroidJava* API to make necessary system calls, adjust Screen.orientation accordingly. Or set your game to a fixed orientation in the Player settings.
Your answer
Follow this Question
Related Questions
OS Status Bar and Rotation on Android 0 Answers
Application always launches with same orientation on Android, regardless of OS orientation. 1 Answer
Android screen rotation very slow and my audio keeps going but the graphics stop 0 Answers
Problem using WebCamTexture.videoRotationAngle on Android 0 Answers