private void Awake() { if (instance != null && instance != this) { Destroy(gameObject); return; } else { instance = this; } DontDestroyOnLoad(instance); }
void Awake() { if (instance != null && instance != this) { instance.gameObject.SendMessage("SetMusic", GetComponent <AudioSource>().clip); Destroy(this.gameObject); return; } else { instance = this; } DontDestroyOnLoad(this.gameObject); gameObject.name = "$MusicManager"; }
void Awake() { if (instance != null && instance != this) { instance.gameObject.SendMessage("SetMusic", audioSource.clip); Destroy(this.gameObject); return; } else { instance = this; } DontDestroyOnLoad(this.gameObject); gameObject.name = "$MusicManagerSingleton"; }
void Awake() { if (instance != null && instance != this) { Debug.Log("MusicManagerSingleton already created"); Destroy(this.gameObject); return; } else { Debug.Log("Creating MusicManagerSingleton"); instance = this; } //This prevents that this game object is not destroyed when scene changes DontDestroyOnLoad(this.gameObject); }