Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Bug Screen.SetResolution() skewed rendering right after window mode switch

Discussion in 'Windows' started by kvihola, Nov 23, 2022.

  1. kvihola

    kvihola

    Joined:
    Apr 27, 2017
    Posts:
    6
    I capture Alt-Enter on Windows to switch manually between full screen and windowed mode by calling Screen.SetResolution(width, height, fullscreen). The aspect ratio of the resolution remains the same between the calls, and my FullScreenMode is set to MaximizedWindow in project settings, which should fall back to FullScreenWindow on Windows.

    After the window mode changes, the rendered outcome looks skewed for one frame (when measured from Update() to Update() in the debugger). In practice, the erroneous image could be displayed for longer and it's very noticeable during ordinary play, making things feel not very professional.

    The automatic handling of Alt-Enter by Unity and reacting to window mode changes in Update(), which is what I tried by default, didn't fare any better.

    Am I missing something, and if not, is there a way to work around this? Screen.SetResolution() seems like it should provide all the necessary information to Unity in a single call, and it should be possible for Unity to sync the visible effects of the switch to take place all at once.

    I'm running Unity 2021.3.13f1.
     
    SamoVN likes this.
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,756
    Do you have any screenshots of what it looks like?
     
  3. kvihola

    kvihola

    Joined:
    Apr 27, 2017
    Posts:
    6
    Sure! Here's what it looks like coming from full screen SetResolution(1920, 1080, true) to windowed SetResolution(1146, 644, false) on the first frame.

    upload_2022-11-24_1-18-12.png

    This is after the game corrects itself between the calls to Update().

    upload_2022-11-24_1-21-8.png

    My desktop resolution is 3440x1440.
     
  4. kvihola

    kvihola

    Joined:
    Apr 27, 2017
    Posts:
    6
    To make sure I wasn't sending you on a wild goose chase, I looked at whether this happens both at other desktop resolutions, and with a very simple project.

    If I set the desktop resolution to 1920x1080 or 2560x1440, the issue goes away. Whenever I switch back to the display's native 3440x1440, it appears again.

    In a simple project that doesn't do anything custom with resolution or rendering, when you Alt-Enter between full screen and the windowed mode, the same aspect ratio error appears (when the desktop resolution is 3440x1440). This simple project runs on Unity 2020.3.18f1.
     
  5. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,756
    Thanks for the detailed information. We've also heard about this from another customer a day before your forum post. We will take a look & address it.
     
  6. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,756
    Can you actually file a bug report on this for tracking purposes? It helps us gather all the relevant information for when we investigate it.
     
  7. kvihola

    kvihola

    Joined:
    Apr 27, 2017
    Posts:
    6
    Sure!

    IN-24571 - Alt-Enter aspect ratio issue on Windows
     
  8. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,756
    Thanks, we will take a look.
     
    SamoVN likes this.