I can’t seem to get my game to switch to a maximized window where the window is docked to the top of the screen. I’m currently using a UI Slider to choose between these 3 options. My game is a 2D, top-down space shooter, so I want the game to not reveal any more of the level, so I have the window unable to be resized by dragging the sides, but I still want to support some screen variations. Currently I have a system to switch between Fullscreen, a 1920x1080 non-fullscreen window, and a 1024x576 window:
public void setScreenSize(float size) {
switch (size) {
case 0:
Screen.fullScreen = true;
print("FULLSCREEN");
break;
case 1:
Screen.SetResolution(1920, 1080, false);
print("MAXIMIZED WINDOW");
break;
case 2:
Screen.SetResolution(1024, 576, false);
print("WINDOWED");
break;
default:
Screen.fullScreen = true;
break;
}
}
This code works, but I’m not a fan of the 1920x1080 window as it can be moved around, part of the screen is cut off, and it doesn’t match everyone’s resolution. I tried to change the player’s settings through UnityEditor.PlayerSettings.fullscreenMode to change it, but that didn’t let me build it:
public void setScreenSize(float size) {
switch (size) {
case 0:
Screen.fullScreen = true;
print("FULLSCREEN");
break;
case 1:
UnityEditor.PlayerSettings.fullScreenMode = FullScreenMode.MaximizedWindow;
print("MAXIMIZED WINDOW");
break;
case 2:
Screen.SetResolution(1024, 576, false);
print("WINDOWED");
break;
default:
Screen.fullScreen = true;
break;
}
}
My error is: “Assets\Scripts\settingsMenu.cs(75,17): error CS0234: ‘PlayerSettings’ does not exist in the namespace ‘UnityEditor’ (are you missing an assembly reference?)”
Why does UnityEditor.PlayerSettings.fullScreenMode = FullScreenMode.MaximizedWindow;
not work? Is there anyway I can maximize the window through my script? Thank you in advance.
I’ve also tried Screen.fullScreenMode = FullScreenMode.MaximizedWindow;
and that just glitched out a ton.