Search Unity

Saving settings between scenes !

Discussion in 'Scripting' started by Louis-LCM, Nov 22, 2014.

  1. Louis-LCM

    Louis-LCM

    Joined:
    Aug 26, 2014
    Posts:
    59
    Hi everybody !

    I have a mute script attached to a "Settings" scene. How I can use the playerprefs to save and work in another scene ? I tried very much solutions but nothing is working ... :(

    Here is my script:

    Code (JavaScript):
    1. #pragma strict
    2.  
    3.   var muted = false;
    4.   var CustomSkin: GUISkin;
    5.   var musicMute : GUIStyle;
    6.   var allSound : GUIStyle;
    7.  
    8.  
    9.    function Start (){
    10.  
    11.    }
    12.  
    13.   function OnGUI(){
    14.       GUI.skin = CustomSkin;
    15.      
    16.       if(GUI.Button(new Rect(Screen.width * 0.20,Screen.height * 0.40, Screen.width * 0.20, Screen.height * 0.20), "Sound"))
    17.       {
    18.           if(muted == false){
    19.           AudioListener.volume = 0;
    20.           muted = true;
    21.           }
    22.           else{
    23.           AudioListener.volume = 1;
    24.           muted = false;
    25.           }
    26.       }
    27.   }
     
  2. koray1396

    koray1396

    Joined:
    Mar 18, 2014
    Posts:
    10
    to save volume
    PlayerPrefs.SetFloat("audioVolume", AudioListener.volume);

    to retrieve the volume
    AudioListener.volume = PlayerPrefs.GetFloat("audioVolume");
     
    Louis-LCM likes this.
  3. Louis-LCM

    Louis-LCM

    Joined:
    Aug 26, 2014
    Posts:
    59
    Don't work how he's suposed to do :( !
     
  4. Louis-LCM

    Louis-LCM

    Joined:
    Aug 26, 2014
    Posts:
    59