Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by RobertWebb · Feb 27, 2017 at 02:34 PM · androidorientationscreen.widthgalaxyscreen.height

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: alt text

Started portrait then rotated to landscape: alt text

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.

badwidthportrait.png (469.2 kB)
badwidthlandscape.png (426.9 kB)
Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image RobertWebb · Mar 01, 2017 at 05:43 AM 0
Share

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?

avatar image RobertWebb · Mar 11, 2017 at 10:39 AM 0
Share

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) : alt text

Start portrait, turn to landscape (doesn't work) : alt text

Is the Galaxy S2 no longer supported by Unity?

goodportrait.png (118.5 kB)
badlandscape.png (86.5 kB)

1 Reply

· Add your reply
  • Sort: 
avatar image
0

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges