public Texture2D icon;
public Texture2D iconClicked;
public GUISkin toggleSkin;
private bool muteToggle = false;
private bool toggleImg = false;
public UIToggle toggle;
// Use this for initialization
void Awake () {
if (PlayerPrefs.GetInt ("SoundMute") == 1) {
toggle.value = true;
} else {
toggle.value = false;
}
}
// Update is called once per frame
void Update () {
if (Application.loadedLevel == 0) {
if(toggle != null && toggle.value == true ){
PlayerPrefs.SetInt("SoundMute", 1);
Invoke("audioOff", 0.01f);
} else{
Invoke("audioOn", 0.01f);
PlayerPrefs.SetInt("SoundMute", 0);
}
}
}
void audioOn(){
audio.volume = 1;
}
void audioOff(){
audio.volume = 0;
}