static void Main(string[] args) { AbstractSingleton singleton = Singleton.getInstance(); singleton.DisplayMessage(); Console.ReadKey(); }
public static AbstractSingleton getInstance() { if (INSTANCE == null) { INSTANCE = new Singleton(); } return(INSTANCE); }
protected virtual void Awake() { //Check if instance already exists if (Instance == null) { //if not, set instance to this Instance = this; } //If instance already exists and it's not this: else if (Instance != this) { Destroy(gameObject); } }