All compiler error

hey friends,
I’ve been running into this error ‘‘All compiler errors have to be fixed before you can enter playmode! UnityEditor.SceneView:ShowCompileErrorNotification()’’
visual studio1
error visual studio1

I feel like no matter what I type after the ‘void update’ section the error keeps on popping up
please advise!

Hi there,

First of all, the console does state what the error is, you need to scroll to see it, or just hit “Clear”, which will clear all console messages except from errors. If you want to see that error in Visual Studio, hover the mouse over the red squiggly line to see it.

Could you also post your code here? Don’t forget to format it so that it’s easier to read (see image below). The more info you post here, the easier it is for us to help you :slight_smile:

aaa

Dear Michael, 
thanks for your reply
here is the code that i've copied from Unity documentation
 {
        {  if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            Debug.Log("Space key was pressed.");
        }
    }
    

strangest thing is that everything works before i get into the ‘‘void update’’ section, even when i remove the code same error keeps on showing on and on again!
thank you

Could you post the WHOLE script?

By the way, if this is indeed the code, you have an extra curly brace before the “if” statement.

here i’'m pasting the whole thing

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

public class NumberWizzard : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        int max = 1000;
        int min = 1;
        Debug.Log("Welcome to Number Wizzard!");
        Debug.Log("Pick a nmber, don't tell me what it is....");
        Debug.Log("The highest number you can pick is " + max);
        Debug.Log("The lowest number you can pick is " + min);
        Debug.Log("Tell me if your number is higher or lower than my guess");
        Debug.Log("Push up = higher, Push Down = Lower, Pus Enter = Correct");
    }

    // Update is called once per frame
    void Update()
    {
        {  if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            Debug.Log("Space key was pressed.");
        }
    }
    

Yep, that extra curly brace before the “if” statement might do the trick, try removing that.

thank you, i did remove the extra curly bracket and clicked save, yet nothing changed.
Here is the script

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

public class NumberWizzard : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        int max = 1000;
        int min = 1;
        Debug.Log("Welcome to Number Wizzard!");
        Debug.Log("Pick a nmber, don't tell me what it is....");
        Debug.Log("The highest number you can pick is " + max);
        Debug.Log("The lowest number you can pick is " + min);
        Debug.Log("Tell me if your number is higher or lower than my guess");
        Debug.Log("Push up = higher, Push Down = Lower, Pus Enter = Correct");
    }

    // Update is called once per frame
    void Update()
    {
         if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            Debug.Log("Space key was pressed.");
        }
    }
    

I just noticed that you’re also missing the closing curly brace at the end of the script, the one that should be enclosing the whole class.

If you hover your mouse over the red squiggly line, you’ll see the compiler complaining that it is expecting a " } ".

Yey! it worked!
Thank you Michael!

Cheers!
Make sure to mark the message that helped you as a solution, it helps our lovely moderators. Have a nice day.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.