Last active
May 19, 2017 18:46
-
-
Save lincerely/4d29c94f34fc60c72683c2897496f958 to your computer and use it in GitHub Desktop.
Unity Singleton GameManager
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 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