I'm trying to get a fullscreen toggle button working in C# code with Unity

681 Views Asked by At
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Fullscreentoggle : MonoBehaviour
{
    public void SetFullscreen (bool isFullscreen)
    {
        Screen.fullScreen = isFullscreen;
    }
}

Doesn't work, still don't know why. If someone can send a working script for this it would be much appreciated!

1

There are 1 best solutions below

4
On

Suggestions:

I believe you should change the fullScreenMode as well to what ever you prefer.

Screen.fullScreen = isFullscreen;
Screen.fullScreenMode = FullScreenMode.FullScreenWindow;

Hope it works... Happy coding :)