I'm currently working on a game and I was making it's options menu and started scripting the fullscreen toggle. The code I've used for this can be found in a Brackeys tutorial but even after following whatever they did I've ran into this error:
Assets\Code\OptionsMenuScript.cs(44,16): error CS0117: 'Screen' does not contain a definition for 'fullscreen'
Most of the code in OptionsMenuScript.cs is useless in this question so I'll narrow it down to the important parts.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class SwitchToFullscreen : MonoBehaviour
{
public void SetFullscreen(bool isFullscreen)
{
Screen.fullscreen = isFullscreen;
}
}
Even after looking in Project Settings several times I still haven't found a way to fix this. Am i supposed to define screen
somewhere in my code? Is screen
in the Project Settings but under a different name? Can anybody help me with this?
Also, if anyone needs it, I'm using Unity 2021.3.3f1 (3D Project).
CodePudding user response:
public void SetFullscreen(bool isFullscreen) {
Screen.fullScreen = isFullscreen;
}
your Screen.fullScreen doesn't match with capitalization which I believe is throwing the errors. I tested using the code written above and received no errors in visual studio.