I have to toggles on my main menu one that mutes sound “MuteToggle” and one that should just mute Music “MusicToggle” the music toggle is meant to mute audio with the tag “music” and it dosent. It only mutes the music one the first scene and not the rest
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Audio;
public class MuteAudio : MonoBehaviour
{
public void MuteToggle(bool muted)
{
if (muted)
{
AudioListener.volume = 0;
}
else
{
AudioListener.volume = 1;
}
}
public void MusicToggle(bool muted2)
{
if (muted2)
{
GameObject.FindWithTag("Music").GetComponent<AudioSource>().mute = true;
}
else
{
GameObject.FindWithTag("Music").GetComponent<AudioSource>().mute = false;
}
}
}
}