Hello,
I need help with screen rotation on my android app.
I have two scenes, one should be portrait only and second should be landscape only.
For portrait scene I added script to “Main Camera” :
public void Awake()
{
Screen.orientation = ScreenOrientation.Portrait;
}
// Update is called once per frame
void Update()
{
Screen.autorotateToPortrait = true;
Screen.autorotateToPortraitUpsideDown = true;
Screen.autorotateToLandscapeLeft = false;
Screen.autorotateToLandscapeRight = false;
}
For landscape scene I added script to “Main Camera” :
// Start is called before the first frame update
public void Awake()
{
Screen.orientation = ScreenOrientation.LandscapeLeft;
}
// Update is called once per frame
void Update()
{
Screen.autorotateToPortrait = false;
Screen.autorotateToPortraitUpsideDown = false;
Screen.autorotateToLandscapeLeft = true;
Screen.autorotateToLandscapeRight = true;
}
Everything works fine, but the problem is that when the scenes switches screen rotation is delayed. For example, I have my portrait scene and I switch to next scene and my landscape scene is still in portrait and stretched for a second , then switches to landscape and vice versa.
I need your help where to attach this script or use other script so that screen rotation happens before scene loads. I hope you understood my problem and could explain me what I’m doing wrong.
Thank you for your time !