using System.Collections; using System.Collections.Generic; using UnityEngine; public class MusicScript : MonoBehaviour { private AudioSource audioSource; private void Awake() { DontDestroyOnLoad(transform.gameObject); audioSource = GetComponent(); } public void PlayMusic() { if (audioSource.isPlaying) return; audioSource.Play(); } public void StopMusic() { audioSource.Stop(); } }