- Home /
Screen.width & height not updated after screen rotation
When rotating a device (eg landscape to portrait) Screen.width and Screen.height normally swap. This works for me on Galaxy S5, but not on Galaxy S2. On S5, I rotate the screen and the app resizes appropriately. On S2, the app is still trying to render at the original size (either portrait or landscape, depending on the orientation when the app was started). There's a black section because the app doesn't reach in one direction, and the app itself is cropped because it's too big in the other direction. See screenshots:
Started landscape then rotated to portrait:
Started portrait then rotated to landscape:
I'm sure this worked in an older version of my app, so maybe this is a bug that appeared in a newer version of Unity? I'm using 5.5.0f3.
Just to clarify:
The black sections above shouldn't be there.
The app DOES rotate when the device orientation is changed, but it doesn't resize to fit, and Screen.width and Screen.height don't swap as they should. You can see the incorrect values displayed in the first screenshot.
Works as expected on Galaxy S5, but not on S2. Anyone know why?
Any help here? Surprised no one else is reporting this. $$anonymous$$aybe the S2 is considered too old to care about now?
I created a new sample project, and the same problem. Screen.orientation updates correctly when rotating the device, but Screen.width and Screen.height don't swap as they should (as they do on other platforms), and the image is rendered with the wrong aspect.
These screenshots are probably a bit clearer, with Screen.width, Screen.height, and Screen.orientation displayed, and a sphere that should be in the middle of the screen.
Start portrait and view portrait (works as it should) :
Start portrait, turn to landscape (doesn't work) :
Is the Galaxy S2 no longer supported by Unity?
Answer by RobertWebb · Mar 14, 2017 at 08:22 AM
Looks like this was fixed in a latest version. They move so quick! It was the bug described here.
Your answer
Follow this Question
Related Questions
Do screen.width and screen.height get updated depending on screen orientation on Android? 1 Answer
Android screen orientation: why am I getting wrong screen size values? 1 Answer
Unity 3.5.7 Android Screen returns the wrong value? 0 Answers
Screen.width and Screen.height sometimes flipped for Android 1 Answer
When are Screen.width and Screen.height updated after changing the Screen.orientation value? 0 Answers