public void SoundButtonClick() { if (PlayerPrefs.GetInt("ISSOUNDON") == 0) { Debug.Log("Make sound on"); PlayerPrefs.SetInt("ISSOUNDON", 1); SoundBtn.GetComponent <Image>().color = Color.green; SoundBtn.GetComponentInChildren <Text>().text = "ON"; } else { Debug.Log("Make sound off"); PlayerPrefs.SetInt("ISSOUNDON", 0); SoundBtn.GetComponent <Image>().color = Color.red; SoundBtn.GetComponentInChildren <Text>().text = "OFF"; //Do your stuff here } }
void InitializeScene() { if (PlayerPrefs.GetInt("ISMUSICPLAYING") == 1) { MusicBtn.GetComponent <Image>().color = Color.green; MusicBtn.GetComponentInChildren <Text>().text = "ON"; } else { MusicBtn.GetComponent <Image>().color = Color.red; MusicBtn.GetComponentInChildren <Text>().text = "OFF"; } if (PlayerPrefs.GetInt("ISSOUNDON") == 1) { SoundBtn.GetComponent <Image>().color = Color.green; SoundBtn.GetComponentInChildren <Text>().text = "ON"; } else { SoundBtn.GetComponent <Image>().color = Color.red; SoundBtn.GetComponentInChildren <Text>().text = "OFF"; } }