예제 #1
0
        private static void MakeSingleton(RootBehaviour instance)
        {
            UnityEnsure.Argument.NotNull(instance, nameof(instance));

            foreach (var inst in _instances.Where(inst => inst != instance).ToArray())
            {
                DestroyInstance(inst);
            }
        }
예제 #2
0
 private void OnDestroy()
 {
     Instance = null;
 }
예제 #3
0
 private void Awake()
 {
     MakeSingleton(this);
     Instance = this;
 }
예제 #4
0
 private static void DestroyInstance(RootBehaviour inst)
 {
     UnityObjectUtil.Destroy(inst.gameObject);
     _instances.Remove(inst);
 }