Is there a way to toggle the Player setting's 'auto-rotate' (for mobile builds) from script?
The Auto-rotate function built in to Unity isn't calibrated properly, and even when the tablet/device's auto-rotate is locked OFF, unity still rotates the screen. I am getting more familiar with android system settings so eventually I would like my app to check the device's system setting for auto-rotate to determine whether to rotate the screen or not.
To clarify, I assume you can shut auto-rotate off in the Android build settings, but is there a way to toggle it in a compiled player, or is it set to on/off at compile time?
Yes you can. here check this documentation pages. they are pretty straightforward. if you need further help or maybe, just comment below.
BEST ANSWER (from NorthStar79)
Yeah thanks, both came in handy. I underestimated how thorough the documentation was, and how many built-in functions Unity has. I'm impressed. -To clarify, it seems to only happen on two out of four mobile devices I've tried so far, it automatically rotates the screen when the tablets are only barely tilted, and when you lock the tablet's 'auto-rotate' setting to OFF, Unity ignores that and rotates anyways.
Answer by Honorsoft · Apr 02, 2018 at 04:45 AM
NorthStar79 · Feb 09 at 02:36 PM Yes you can. here check this documentation pages. they are pretty straightforward. if you need further help or maybe, just comment below.
Screen.orientation
Input.deviceOrientation
Your answer
![](https://koobas.hobune.stream/wayback/20220612105921im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
how to convert a dynamic playerpref to a dynamic int variable? 0 Answers
need help with code please 1 Answer
Big numbers 2 Answers