Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by cregox · Dec 09, 2011 at 08:49 PM · fullscreenwindows-standalone

Identifying Windows resolution change at runtime

Trying a compiled project in a new windows powered tablet, which we were experimenting here, I noticed a problem anyone can try at a desktop Windows. In the tablet, all you have to do is rotate it, and the screen will flick.

To simulate it on a desktop windows, hold SHIFT before running the EXE and play it at full screen. CTRL+ESC out of it, right click on the desktop and open up Screen Resolution Windows Dialog. Set Orientation to anything other than the current one, press Apply, ALT+TAB back to the application.

The screen will flick a lot and if you wait for the 20 seconds for Windows to auto revert back to default settings, you'll be able to see your app running normally back again.

Plus, under [APPLICATION]_Data folder the output_log.txt may have at least a line similar to the ones I get:

 (Filename: C:/BuildAgent/work/842f9557127e852/Runtime/ExportGenerated/StandalonePlayer/UnityEngineDebug.cpp Line: 34)
 
 Skipped rendering frame because GfxDevice is in invalid state (device lost)
  
 (Filename: C:/BuildAgent/work/842f9557127e852/Runtime/Misc/Player.cpp Line: 1466)
 
 D3D device reset failed [invalid call]
  
 (Filename: C:/BuildAgent/work/842f9557127e852/Runtime/GfxDevice/d3d/D3D9Context.cpp Line: 456)
 
 Skipped rendering frame because GfxDevice is in invalid state (device lost)

Any ideas on how to fix this?

Comment
Add comment · Show 6
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 Turing_machine · Nov 29, 2012 at 09:21 AM 0
Share

Same problem. Does anybody figured out how to fix it?

avatar image cregox · Nov 29, 2012 at 12:45 PM 0
Share

@Turing_machine nothing here yet. Thankfully it is not a critical issue. But if you've got same problem, voting up the question might help getting visibility to it.

avatar image Dave-Carlile · Nov 29, 2012 at 01:41 PM 0
Share

I'm curious if you see the same thing when starting another game or app that requires the graphics hardware? I actually see that in the Unity editor - if I start a game while the editor is running, when I come back to the editor the screen is black, and there are a lot of failures in the log where Unity is trying to handle the "device lost" state. The only way to recover is to select a window layout, which seems to reset everything properly. Anyway, it seems like Unity isn't properly handling "device lost", at least in some instances.

avatar image cregox · Dec 04, 2012 at 11:29 AM 0
Share

@Turing_machine that sounds like a worse solution than using `Screen.currentResolution` as Jordan suggested on his/her answer there. Have you tried that first (on your resolution checker script maybe)?

avatar image Turing_machine · Dec 04, 2012 at 11:32 AM 1
Share

of course, and as i've mentioned, unity just gave me the same resolution that was before i've changed orientation in both fullscreen and windowed modes

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Turing_machine · Dec 04, 2012 at 11:23 AM

i've kinda got the way to fix this - problem is that unity doesnt check how it's oriented on focus, that means it still thinks it's the same orientation, and gets Screen.height the same, despite that it becomes width. My problem was that I've got "resoulution checker" script, that tries to set corect resolution, and it worked wrong of course. So i've just got actual height and width of the screen using winAPI(user32.dll) directly, to find out actual orientation and correctly handle it.

Comment
Add comment · Show 3 · 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
avatar image cregox · Dec 04, 2012 at 11:45 AM 0
Share

Even though I won't be able to test this for a while, sounds like a solution and the only one so far! Thanks. :-)

avatar image AndantaCompany · Nov 23, 2016 at 11:56 AM 0
Share

Could you please share the code or the namespaces you used for this?

avatar image Bunny83 AndantaCompany · Nov 23, 2016 at 12:19 PM 0
Share

$$anonymous$$ost likely something like the example code at the bottom of this $$anonymous$$SDN page. Note: I'm not sure how well this behaves in multi-monitor setups ^^.

Another quick google revealed this. So GetSystem$$anonymous$$etrics always return the resolution of the primary monitor.

avatar image
0

Answer by Landern · Nov 29, 2012 at 02:25 PM

If you start in windowed mode, you can use Screen.currentResolution to get the current desktop resolution. You can go into full screen with Screen.fullScreen.

Comment
Add comment · Show 2 · 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
avatar image cregox · Dec 04, 2012 at 11:28 AM 0
Share

And would that magically solve the flickering or allow me to identify the resolution change? I'm asking because I won't be able to test it in a long while now. But Turing_machine there says it won't work.

avatar image Turing_machine · Dec 04, 2012 at 11:42 AM 0
Share

doesn't worked for me. Screen.currentResolution just returns same value, so it doesn't helped to check if orientation was changed

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

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Block or Override Alt-Enter Fullscreen 4 Answers

Standalone application fullscreen 3 Answers

Play movie in full screen 1 Answer

Fullscreen WebPlayer crash (white screen) 0 Answers

Running two games, one different monitors on the same computer. 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