How do I save volume of my audio source (clicking the mute button) when game is restarted. You see I have one scene in my game and once the player dies there is a button the user can click on that resets the game, however it also resets the audio source, so when I play the game and click my mute button, the audio source volume is at 0 but when I die and click the reply button (the restart/reset button) the music is restarted as well, instead of staying muted (save the current volume). I tried using DontDestroyOnLoad(this) but my muted script is attached to my game over panel animation (the panel comes down when player dies) making the my game over panel animation not being destroyed when you restart the game. I tried other methods like putting my mute button script on a parent empty object and putting the object that has the audio source on under it as a child but it did the same thing. Anyway this is my mute button script:
private bool mute;
public void Muted ()
{
mute = !mute;
if (mute){
gameObject.GetComponent<AudioSource>().volume = 0;
}else
{
gameObject.GetComponent<AudioSource>().volume = 1;
}
}
}
And this is my restart level when button is pressed (p.s. I used the OnClick method activating methods):
public void NavigateTo(int scene)
{
Application.LoadLevel ("Game Level");
}
Thank you in advance :)