Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Bug Maximize window stretches camera rect

Discussion in 'Editor & General Support' started by crudeMe, Sep 17, 2021.

  1. crudeMe

    crudeMe

    Joined:
    Jul 8, 2015
    Posts:
    92
    Hi,
    I'm using Unity 2021.2.0b6. Building a standalone player with Fullscreen Mode: Windowed. When I click maximize window system button, window do get maximized but camera rect stretches.

    Okay, let's try to figure out when window gets maximized and set resolution. Well, you can't get when window is maximized out of the box -
    Screen.fullScreenMode
    on Update loop always giving me Windowed even after window gets maximized.

    Okay, well, let's try to get anything from resolution. Let's try to compare Screen.width with Display.displays[Camera.targetDisplay].systemWidth to see if window is maximized or full width. And change resolution to native full screen with Screen.SetResolution(systemWidth, systemHeight, false, 0). Well, no. Now build is crashing with "Couldn't switch to requested monitor resolution" (DX11 could not switch resolution).

    As I see it, there are two separate problems: MaximzeWindow event not processed correctly and SetResolution issue. I've found several hacks about starting with Maximized Window, but they aren't exactly helping.

    So, what am I doing wrong? I just want to maximize my game window.
     
  2. crudeMe

    crudeMe

    Joined:
    Jul 8, 2015
    Posts:
    92
    Okay, seems like Unity 2021.1.21f1 handles window maximizing correctly. Thanks everyone