Skip to content

Instantly share code, notes, and snippets.

@umuralpay
Created March 10, 2020 16:31
Show Gist options
  • Save umuralpay/54c7805e24150bee5873c779679c1daf to your computer and use it in GitHub Desktop.
Save umuralpay/54c7805e24150bee5873c779679c1daf to your computer and use it in GitHub Desktop.
Unity Singleton
int numGameOfSessions = FindObjectsOfType<GameSession>().Length;
if(numGameOfSessions > 1) {
Destroy(gameObject);
}else {
DontDestroyOnLoad(gameObject);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment