UnityEngine.Screen does not contain a definition for 'fullscreen'

It’s been a whole two weeks now with my fullscreen bug, and it seems that no one cares anymore, and I can’t seem to figure it out myself, now I have updated my code to better fit the toggle button, and I get a total of 13 errors in this order:

A ‘using’ directive can only be applied to namespaces but ‘UnityEngine.Screen’ denotes a type. Consider using a ‘using static’ instead “Line 4”

Feature ‘using static’ cannot be used because it is not part of the C# 4.0 language specification “Line 4”

Unexpected symbol ‘public’, expecting ‘,’ or ‘;’ “Line 5”

The contextual keyword ‘var’ may only appear within a local variable declaration “Line 15”

‘UnityEngine.Screen’ does not contain a definition for ‘fullscreen’ “Line 15”

‘UnityEngine.Screen’ does not contain a definition for ‘fullscreen’ “Line 16”

‘UnityEngine.Screen’ does not contain a definition for ‘fullscreen’ “Line 17”

The left hand side of an assignment must be a variable, a property or an indexer “Line 26”

The left hand side of an assignment must be a variable, a property or an indexer “Line 27”

The left hand side of an assignment must be a variable, a property or an indexer “Line 28”

‘UnityEngine.Screen’ does not contain a definition for ‘fullscreen’ “Line 31”

‘UnityEngine.Screen’ does not contain a definition for ‘fullscreen’ “Line 32”

‘UnityEngine.Screen’ does not contain a definition for ‘fullscreen’ “Line 33”

Errors are killing me slowly, but here is the code so you can possibly help:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FullscreenToggle : MonoBehaviour
{
    // Use this for initialization
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        if (!Screen.fullscreen)
        {
            if (Input.GetMouseButtonDown(0))
            {
                RaycastHit hit;
                Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray, out hit, 100.0f))
                {
                    //Replace this with whatever logic you want to use to validate the objects you want to click on
                    if (hit.collider.gameObject.tag == "Toggle")
                    {
                        !Screen.fullScreen = Screen.fullScreen;
                    }
                }
            }
        }
        if (Screen.fullscreen)
        {
            if (Input.GetMouseButtonDown(0))
            {
                RaycastHit hit;
                Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray, out hit, 100.0f))
                {
                    //Replace this with whatever logic you want to use to validate the objects you want to click on
                    if (hit.collider.gameObject.tag == "Toggle")
                    {
                        Screen.fullScreen = !Screen.fullScreen;
                    }
                }
            }
        }
    }
}

Not to be rude or anything, but someone please answer this question this time, this is my fourth time I’ve asked a question related to my games fullscreen bug and not a single person has replied. And at this point I’m done. >:-(

I’m not sure about all the errors at the beginning with the using statements. I think that might be an issue with your Unity setup, but the code itself looks syntactically correct. Although, I think I can help you with your fullscreen issue.

On lines 16 and 32, the issue is that you are trying to access Screen.fullscreen. The problem is that the “s” in fullscreen has to be capitalized. Change it to Screen.fullScreen instead.

Your issue on line 27, is that you have the exclamation symbol in the wrong place. It should look more like this:

                     Screen.fullScreen = !Screen.fullScreen;

Hope this at least helps with part of your problem.

@Jawchewa thank you for helping me, it now turns on, but was is the command for turning it off? I chose to no longer have toggle and replace it with on/off, and the on works, but the off doesn’t. If you have an answer, and it works, I will tell you.