Skip to content

Instantly share code, notes, and snippets.

@surayashivji
Created April 26, 2017 06:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save surayashivji/d634f5408111fdc03ab6b3f778d57f74 to your computer and use it in GitHub Desktop.
Save surayashivji/d634f5408111fdc03ab6b3f778d57f74 to your computer and use it in GitHub Desktop.
Game Manager manages my game and controls pause
using System.Collections;
using System.Collections.Generic;
using UnityEngine.SceneManagement;
using UnityEngine;
public class GameManager : MonoBehaviour {
// Singleton GameManager
public static GameManager Instance { set; get; }
public bool isPaused;
// private Timer timer;
private GameObject pausePanGO;
private void Awake()
{
Instance = this;
DontDestroyOnLoad (this.gameObject);
isPaused = false;
// after loading game content
SceneManager.LoadScene ("MenuScene");
}
public void TogglePause()
{
pausePanGO = GameObject.FindGameObjectWithTag ("pauseGO");
Debug.Log ("toggle pause called");
// timer = GameObject.Find ("Timer").GetComponent<Timer> ();
isPaused = !isPaused;
// pause timer
if (isPaused)
{
Debug.Log ("We are now paused");
// we are now paused
// pause timer, set panel to active
pausePanGO.SetActive(true);
}
else
{
Debug.Log ("unpause the game please");
// unpause game, unpause timer
// set panel to inactive
pausePanGO.SetActive(false);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment