private void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); } DontDestroyOnLoad(gameObject); }
// Use this for initialization private void Awake() { background = GetComponent <AudioSource>(); string scene = SceneManager.GetActiveScene().name; if (instance != null && instance != this) { Destroy(this.gameObject); return; } else { instance = this; background.Play(); } }