Example #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);
            }
        }
Example #2
0
 private void OnDestroy()
 {
     Instance = null;
 }
Example #3
0
 private void Awake()
 {
     MakeSingleton(this);
     Instance = this;
 }
Example #4
0
 private static void DestroyInstance(RootBehaviour inst)
 {
     UnityObjectUtil.Destroy(inst.gameObject);
     _instances.Remove(inst);
 }