So, I’ve already previously used DontDestroyOnLoad in my game in order for the music to seamlessly switch between my main menu and game scenes. However, once the game is over and players click the “Back to Menu” button, my previous music continues to play while a second layer of the same music starts to play on top of it. How can I stop the previous music so that they do not overlap? Is there a way to reload the audio mixer?
public class DoNotDestroy : MonoBehaviour
{
void Awake()
{
GameObject musicObj = GameObject.FindGameObjectsWithTag(“Music”);
DontDestroyOnLoad(this.gameObject);
}
}