Пример #1
0
 void _MakeSingleton()
 {
     if (instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
     }
 }
Пример #2
0
 /*!
  * Méthode qui permet de garder la même musique de fond lors du changement de scènes. Si l'instance courrante n'exite pas, alors elle est créée.
  */
 void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         instance = this;
     }
     DontDestroyOnLoad(this.gameObject);
 }
Пример #3
0
 void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         instance = this;                    // = this scene
     }
     DontDestroyOnLoad(this.gameObject);     // --> don't destroy gameobject when a new scene is loaded
 }