Skip to content

Instantly share code, notes, and snippets.

@lincerely
Last active May 19, 2017 18:46
Show Gist options
  • Save lincerely/4d29c94f34fc60c72683c2897496f958 to your computer and use it in GitHub Desktop.
Save lincerely/4d29c94f34fc60c72683c2897496f958 to your computer and use it in GitHub Desktop.
Unity Singleton GameManager
using UnityEngine;
using System.Collections;
public class GameManager : MonoBehaviour {
public static GameManager manager; //singleton
void Awake(){
if(manager == null){
DontDestroyOnLoad(gameObject);
manager = this;
}else if(manager != this){
Destroy(gameObject);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment