I would use an AudioSource, because this can change between multiple AudioClip, which is a specific sound, so you can play multiple sounds.
You'll have to attach all needed components in editor before this.
- An AudioSource component to your AudioSource field and drag the AudioClip into that AudioSource Component.
- A Button component on the btnMusic field.
- An Animator on the animator field and create an animation in the Animator tab in the editor.
Then in your GameManager you can do something like this:
public AudioSource audioSource;
public Animator animator;
public Button btnMusic;
void Start()
{
audioSource.Play("name-of-your-audio-clip");
btnMusic.onClick.AddListener(BtnMusicOnClick);
}
void BtnMusicOnClick(){
if (audioSource.isPlaying) {
audioSource.Pause();
} else {
audioSource.UnPause();
}
animator.Play("btnMusicOnClick");
}