예제 #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();
            }
        }