Unity 2018 Windows 10 | Can't switch out of Full screen mode in build (Possible Solution)

The Problem:
When building an in game options menu to replace Unity’s Default Resolution dialogue I noticed that while it was possible to enter fullscreen mode form windowed using:

Screen.fullscreen  = true;

It was not possible to then exit fullscreen mode by setting the same value to false. I did quite a bit of googling and wasn’t really able to find anyone else who had the same problem, much less a viable solution.

But since I have since solved it I thought I’d throw up this thread in case anyone else has run into the issue so that in future it’s there should someone go looking.:slight_smile:

How I solved it:
I was able to force unity to exit fullscreen by manually setting the resolution of the game window and changing the value of the fullscreen variable there. The code for my solution looks like this:

    public void SetFullScreen(bool fullScreenValue)
    {
        Screen.fullScreen = fullScreenValue;
        if (!fullScreenValue)
        {
            Resolution resolution = Screen.currentResolution;
            Screen.SetResolution(resolution.width, resolution.height, fullScreenValue);
        }
       
    }

Hope this helps!

4 Likes

You saved my day!!
Thanks a lot!

Thank you so much I’ve been suffering with this issue since yesterday , you saved me, but I wonder what is the reason of that issue, do you think it is Unity issue ?

Although the code may work, you probably want to move the Screen.fullScreen line to an Else condition (since there are reports that setting it to false has no effect)

Thanks man, i ran into the exact same problem, Ramezov linked me your solution and it worked !

Thanks so much for posting this Todatsu

life saver!!

Thank you so much for this.

thank you!