Created
April 26, 2017 06:20
-
-
Save surayashivji/d634f5408111fdc03ab6b3f778d57f74 to your computer and use it in GitHub Desktop.
Game Manager manages my game and controls pause
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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