Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- public class MusicPlayer : MonoBehaviour
- {
- static MusicPlayer instance = null;
- void Awake ()
- {
- if (instance != null)
- {
- Destroy (gameObject);
- }
- else
- {
- instance = this;
- GameObject.DontDestroyOnLoad (gameObject);
- }
- }
- void Update ()
- {
- Scene currentScene = SceneManager.GetActiveScene ();
- string sceneName = currentScene.name;
- if (sceneName == "GameOver" || sceneName == "Win")
- {
- Destroy (this.gameObject);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement