I have a dropdown with two options, fullscreen and windowed. Using the two lines I’ve commented out it works just fine, but the windowed mode is the size of the whole screen and part of it is under the windows taskbar. I want to eliminate this problem. When windowed mode is chosen it should display a window that’s half the size of the players monitor.
What I have written below is what I think should do this, and it does, but it has problems. Going from fullscreen to windowed works fine, but going from windowed to fullscreen makes the game fullscreen again but leaves the lower resolution so everything goes blurry. Also, if I switch to windowed mode and exit the game and then run it again and it pulls from playerprefs that windowed mode should be running, but with each additional opening of the game it cuts the window size in half again so that eventually running the game produces a little tiny window.
What am I doing wrong here?
public void SetScreenMode () {
if (screenModeDropdown.value == 0) {
//Screen.fullScreen = true;
Screen.SetResolution (Screen.width, Screen.height, true);
}
else if (screenModeDropdown.value == 1) {
//Screen.fullScreen = false;
Screen.SetResolution (Screen.width / 2, Screen.height / 2, false);
}
PlayerPrefs.SetInt ("ScreenMode", screenModeDropdown.value);
}