Search Issue Tracker

Won't Fix

Votes

1

Found in

2022.3.1f1

2023.1.0f1

2023.2.0a19

Issue ID

UUM-40102

Regression

No

Screen.currentResolution value returns the wrong value

-

How to reproduce:
1. Open the “Resolution_Bug“ project
2. Open the “MainMenu“ scene
3. Build And Run (File > Build And Run)
4. In Player navigate to the “Options“ menu
5. Untick the “Fullscren” field
6. Change the “Resolution” field to any other resolution
7. Select “Save Options” and select “Yes”
8. Observe the Player viewport

Expected result: “New Resolution” message is logged with the selected resolution
Actual result: “New Resolution” message is logged with the resolution of the monitor

Reproduced with: 2022.3.1f1, 2023.1.0f1, 2023.2.0a19
Could not test with: 2021.3.27f1 (Changing the resolution does not work)

Reproduced on: macOS 13.2.1 (Intel), Windows 10 (by reporter), Windows 11

Notes:
1. In 2023.1 and 2023.2 streams the resolutions are not displayed in Player but can be found in Player.log
2. In Windows Player.log can be found in User > AppData > LocalLow > DefaultCompany > RunHideWin
3. Cannot test in Editor as Screen.setResolution does not change the resolution of Game view

  1. Resolution Note:

    The bug is a result of a combination of user misunderstanding and an error in our API documentation for the Screen.setResolution function. The API documentation was mistakenly modified by our technical writer intern in a pull request (PR). In previous versions of Unity Docs (2021.2 and earlier), it states that when the player is in windowed mode, the function returns the current resolution of the desktop. However, in versions 2021.3 and later, it states that it returns the current dimensions of the game window in pixels and the display refresh rate when in windowed mode.
    After consulting with the author of the code, our implementation of setResolution, regardless of the platform, always returns the desktop display resolution when in windowed mode, irrespective of the window size. To obtain the dimensions of the game window in pixels, users should utilize the Screen.width and Screen.height APIs instead.
    In windowed mode, the concept of "resolution" does not exist for a Unity player. The Screen.resolutions API documentation explicitly states that it "Returns all full-screen resolutions that the monitor supports"
    I have reached out to the documentation team to request a reversion of the documentation back to its original form.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.