- Home /
 
               Question by 
               Haythamcrc · May 20, 2016 at 12:35 AM · 
                playerprefstoggle  
              
 
              Save a Toggle Group state?
Hi, Here is my current music mute code, which works perfectly. just what i need. but can't get the state of the toggle to stay as it should when resetting the scene.
Thanks to anyone who can help!
 using UnityEngine;
 using System.Collections;
 using UnityEngine.UI;
 
 public class PauseMenuScriptToggle : MonoBehaviour 
 {
     const float DefaultVolumeLevel = 1.0f;
     bool isMute;
     public bool isOn;
 
     void Start()
     {
         audio.volume = PlayerPrefs.HasKey("CurVol") ? PlayerPrefs.GetFloat("CurVol") : DefaultVolumeLevel;
     }
 
     public void MusicMute ()
     {
         if(isMute == true){
             Debug.Log("Music On");
             audio.volume = 1.0f;
             isMute = false;
 
         }
         else 
         {
             Debug.Log("Music Off");
             isMute = true;
             audio.volume = 0;
 
         }
 
         PlayerPrefs.SetFloat("CurVol", audio.volume);
         PlayerPrefs.Save();
     }   
 
 
 }
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                