So I keep getting this error “Namespace cannot directly contain members such as fields or methods”. I’m not sure what’s wrong as I’m quite new.
using UnityEngine;
using UnityEngine.SceneManagment;
public class GameManager :
MonoBehavior
{
bool gameHasEnded = false;
public void EndGame ()
{
if (gameHasEnded == false)
{
gameHasEnded = true;
Debug.Log(“GAME OVER”);
Invoke(“Restart”, 2f);
}
}
}
public void Restart ()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}