Пример #1
0
        public static void Dispose()
        {
            if (instance != null && !destroyed)
            {
                Destroy(instance.gameObject);

                instance = null;
            }
        }
Пример #2
0
        public void OnDestroy()
        {
            Destroy();
            destroyed          = true;
            needInitialization = true;

            if (setToNullAfterDestroy)
            {
                instance = null;
            }
        }
Пример #3
0
        public void Awake()
        {
            if (instance == null || destroyed)
            {
                instance  = this;
                destroyed = false;
            }
            else if (instance != this)
            {
                Debug.LogError("Two instances of the same singleton '" + this + "'");
            }

            if (needInitialization)
            {
                needInitialization     = false;
                initializedAtLeastOnce = true;

                Initialize();
            }
        }