Пример #1
0
        static void Main(string[] args)
        {
            AbstractSingleton singleton = Singleton.getInstance();

            singleton.DisplayMessage();

            Console.ReadKey();
        }
Пример #2
0
        public static AbstractSingleton getInstance()
        {
            if (INSTANCE == null)
            {
                INSTANCE = new Singleton();
            }

            return(INSTANCE);
        }
Пример #3
0
 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);
     }
 }