示例#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);
 }