Created
September 17, 2016 16:40
-
-
Save GarethIW/4041cb70d799ba86a707b72945d8a7f2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
public class Singleton : MonoBehavior | |
{ | |
private static Singleton _instance; | |
public static Singleton Instance | |
{ | |
get { return _instance; } | |
} | |
private void Awake() | |
{ | |
if (_instance != null && _instance != this) | |
{ | |
Destroy(this.gameObject); | |
} | |
else | |
{ | |
_instance = this; | |
DontDestroyOnLoad(this.GameObject); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment