It seems to me that this behavior is incorrect (or at least illogical). Correct me if I'm wrong.
Repro (Unity 2020.3.26f1 LTS / default project settings):
Actual results:
- When going back to fullscreen mode resolution is being kept 500x500 pixels (the scene is rendered in 500x500 pixels, the text is blurry and the canvas is squared).
- Both
Screen.currentResolution
&Screen.width/height
have500x500
values.
Expected results:
- Fullscreen-mode should restore the game resolution back to
1920x1080
(as on the 1st screenshot before going to windowed-mode). - Both
Screen.currentResolution
&Screen.width/height
should have the values of1920x1080
.
The problem caused by this behavior is that the user cannot return to full-screen mode with full display resolution after switching to windowed mode and changing the window size.
Component script used in this test:
public class ResolutionInfo : MonoBehaviour
{
public Text text;
private Vector2 _resolution, _currentResolution;
private bool _fullscreen;
void Update()
{
Vector2 resolution = new Vector2(Screen.width, Screen.height);
Vector2 currentResolution = new Vector2(Screen.currentResolution.width, Screen.currentResolution.height);
if (_resolution == resolution && _currentResolution == currentResolution && _fullscreen == Screen.fullScreen)
return;
_resolution = resolution;
_currentResolution = currentResolution;
_fullscreen = Screen.fullScreen;
text.text =
$"FullScreen: {Screen.fullScreen}\r\n" +
$"Screen.currentResolution = {Screen.currentResolution}\r\n" +
$"Screen.width/height = {Screen.width}x{Screen.height}";
}
}
P.S.
Screen.resolutions
list added to the request from Arian Keshvari comment:
Screen.SetResolution(int width, int height, true);
right when fullscreen is enabled. and to find the values ofwidth
andheight
just useScreen.resolutions
and find the biggest supported size \$\endgroup\$Screen.resolutions
values are also incorrect after returning from Windowed mode (on the last screenshot). \$\endgroup\$screen.resolutions
return a list of all supported screen sizes, can you please tell us what are the values in this list? I'm sure one of them is 1920.1080 \$\endgroup\$var display = Display.displays[Camera.main.targetDisplay];
Screen.SetResolution(display.systemWidth, display.systemHeight, true);
\$\endgroup\$