Beispiel #1
0
 //Set the instance to null ondestroy
 void OnDestroy()
 {
     if (Instance == this)
     {
         Instance = null;
     }
 }
Beispiel #2
0
 void Awake()
 {
     if (Instance == null)
     {
         //if not, set it to this.
         Instance = this;
         DontDestroyOnLoad(gameObject);
     }
     else if (Instance != this && Instance != null)
     {
         Destroy(gameObject);
     }
 }