- Home /
Change screen orientation on mobiles immediately, no animation.
i use the code line below to change the device screen orientation:
Screen.orientation = ScreenOrientation.Portrait;
The code is being executed, but the Android system add an inertia animation to it.
Is there a way to get this command executed immediately, no delay, no inertia, no lag, no animation?
Answer by NoseKills · Jun 19, 2016 at 09:15 AM
On iOS theres the PlayerSettings 'use animated autorotation'. Maybe that's enough.
On Android it seems to be a operating system feature and can't be done at least from unity. Maybe not at all
Thanks. I didn't find anything more on that myself. At least I will have it sorted out for iOS.
I have to initialize some objects in the given orientation state. The transition takes around 0.1 - 0.15s on Galaxy S6.
I have to check if transition is completed within the IEnumerator:
bool completed = Screen.orientation == ScreenOrientation.Portrait;
Screen.orientation = ScreenOrientation.Portrait;
while(!completed)
{
completed = (Screen.orientation == ScreenOrientation.Portrait);
yield return null;
}