示例#1
0
 private void OnDestroy()
 {
     if (_instance == this)
     {
         _instance = null;
     }
 }
示例#2
0
 private void Awake()
 {
     if (_instance != this && _instance != null)
     {
         Destroy(gameObject);
         return;
     }
     if (_instance == null)
     {
         _instance = this;
         return;
     }
     if (_instance == this)
     {
         throw new Exception($"Why am I added two  times?");
     }
 }