Skip to content

Instantly share code, notes, and snippets.

@qqpann
Created June 17, 2021 16:23
Show Gist options
  • Save qqpann/011a011f2adfd8296ff6bbc119ccfcf9 to your computer and use it in GitHub Desktop.
Save qqpann/011a011f2adfd8296ff6bbc119ccfcf9 to your computer and use it in GitHub Desktop.
using UnityEngine;
using UnityEngine.SceneManagement;
public class GameManager : MonoBehaviour
{
bool gameHasEnded = false;
public float restartDelay = 2f;
public void EndGame()
{
if (gameHasEnded == false)
{
gameHasEnded = true;
Debug.Log("Game over");
Invoke("RestartGame", restartDelay);
}
}
void RestartGame()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment