void _MakeSingleton() { if (instance != null) { Destroy(gameObject); } else { instance = this; DontDestroyOnLoad(gameObject); } }
/*! * 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); }
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 }