Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android game always rotates to landscape orientation on startup #2210

Open
dtaylorus opened this issue Feb 14, 2025 · 1 comment
Open

Android game always rotates to landscape orientation on startup #2210

dtaylorus opened this issue Feb 14, 2025 · 1 comment
Labels
enhancement New feature or request

Comments

@dtaylorus
Copy link

When I'm holding the Android device in portrait orientation and start my game which also supports portrait orientation, the screen rotates to landscape for a couple of seconds before rotating back to portrait.

Expected: Start the game in portrait orientation and stay in portrait orientation without rotating to landscape.

@dtaylorus
Copy link
Author

The issue is that AndroidGameWindow.SetOrientation(DisplayOrientation newOrientation, ...) is initially called with newOrientation = DisplayOrientation.Default, which the method does not evaluate as a supported orientation and coerces into LandscapeLeft.

I resolved this issue by changing:

if ((supported & newOrientation) == 0)

to

if ((newOrientation != DisplayOrientation.Default) && (supported & newOrientation) == 0)

since DisplayOrientation.Default = 0 and doesn't otherwise pass the check for supporting any orientations.

Effectively, this makes DisplayOrientation.Default support any orientation instead of no orientations.

@nkast nkast added the enhancement New feature or request label Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants