Skip to content

Instantly share code, notes, and snippets.

@ellisonleao
Created January 30, 2015 18:38
Show Gist options
  • Save ellisonleao/1040b2273a4f86edb44c to your computer and use it in GitHub Desktop.
Save ellisonleao/1040b2273a4f86edb44c to your computer and use it in GitHub Desktop.
SimpleGameManager.cs
using UnityEngine;
using System.Collections;
// Game States
public enum GameState { INTRO, MAIN_MENU, PAUSED, GAME, CREDITS, HELP }
public delegate void OnStateChangeHandler();
public class SimpleGameManager: Object {
protected SimpleGameManager() {}
private static SimpleGameManager instance = null;
public event OnStateChangeHandler OnStateChange;
public GameState gameState { get; private set; }
public static SimpleGameManager Instance{
get {
if (SimpleGameManager.instance == null){
SimpleGameManager.instance = new SimpleGameManager();
DontDestroyOnLoad(SimpleGameManager.instance);
}
return SimpleGameManager.instance;
}
}
public void SetGameState(GameState state){
this.gameState = state;
OnStateChange();
}
public void OnApplicationQuit(){
SimpleGameManager.instance = null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment