- Home /
Question by
jerald_infante23 · Nov 30, 2020 at 01:59 PM ·
buttontoggle
How do I save toggle state ?
public bool isMuted=false;
void Start()
{
isMuted = PlayerPrefs.GetInt("MUTED") == 1;
AudioListener.pause = isMuted;
PlayerPrefs.GetInt("MUTED");
}
public void MutePressed()
{
isMuted = !isMuted;
AudioListener.pause = isMuted;
PlayerPrefs.SetInt("MUTED", isMuted ? 1 : 0);
}
Comment
LIne 10 doesn't do anything, but otherwise, I don't see anything wrong with your code.
Your answer
Follow this Question
Related Questions
GUI Button which looks like a Toggle 0 Answers
How to reset the state of other buttons when clicking on one of them 0 Answers
UI Button should stay highlighted on click 2 Answers
Toggle button ? 2 Answers