(version 2018.1.1f1) i have a toggle which is being called by a checkbox. Code (CSharp): public void SetFullScreen(bool isFullscreen) { Screen.fullScreen = isFullscreen; } when i click the checkbox (after building the game) it doesnt toggle. but when i exit fullscreen with alt+Enter and then click the checkbox it enters fullscreen again. but it wont switch back to windowed. (the on value change event on the checkbox is selected as dynamic bool)
Any update on this? We're having the same issue with 2018.1.6f1 and aren't having much luck finding a workaround. EDIT: It's worth noting that the toggle code worked in prior updates, so this is almost certainly a new issue. EDIT 2: Found in the Issue Tracker. Please place a vote on https://issuetracker.unity3d.com/is...-unchecked-still-makes-game-start-full-screen to see this prioritized.
I seem to have this in 2018.1.6f1 as well. In Player Settings, I've set Full Screen mode to Windowed, checked Allow Fullscreen Switch and in code I do Code (CSharp): Screen.fullScreenMode = FullScreenMode.Windowed; Screen.fullScreen = false; But still not working. Voted on the issue.
I got the same issue, but to solve that i have done Code (CSharp): Screen.SetResolution(Screen.width, Screen.height, true);
Hi, this code worked for me: Code (CSharp): public static bool FullScreenMode { get { return Screen.fullScreen; } set { FullScreenMode mode =value ? UnityEngine.FullScreenMode.ExclusiveFullScreen : UnityEngine.FullScreenMode.Windowed; Screen.fullScreen = value; Screen.SetResolution(Screen.width, Screen.height, mode); } }
This code worked for me (notice the use of Screen.currentResolution.width, which gives you the screen current resolution instead of Screen.width, which gives you the window resolution): Edited: I set an initial rez value so the windowed mode isn't 0,0 (too small). Code (CSharp): Vector2Int rez = new Vector2Int(1600, 900); public void ToggleFullScreen() { FullScreenMode mode; if (Screen.fullScreenMode == FullScreenMode.Windowed) { //Save the windowed size rez.y = Screen.height; rez.x = Screen.width; // mode = FullScreenMode.FullScreenWindow; Screen.SetResolution(Screen.currentResolution.width, Screen.currentResolution.height, mode); //This is the important part! } else { mode = FullScreenMode.Windowed; Screen.SetResolution(rez.x, rez.y, mode); } }