Save changes in Options scene

I have an Options scene where it’s possible to change the settings, like the volume of the music with GUI horizontal slide bar.

Now if I leave the scene and get back to the Options scene, I want the changes I made will be the same.

This is the JS I use for the slidebar

var musicSlider : float = 0.5;

function OnGUI () {
        		musicSlider = GUI.HorizontalSlider (Rect (497, 613, 638, 22), musicSlider, 0.0, 1.0);
        		audio.volume = musicSlider;
}

Otherside, there’s another problem. The music needs to keep playing even if I change from scenes. How can I do this?

Hope you can help me.

Thanks in advance

For your first answer use PlayerPrefs

For your second answer use Application.LoadLevelAdditive

You can also combine both of these answers, make a check for whether the sound has previously been added (going to and from different scenes) to ensure that you don’t add additional sounds. Also, a better way even then loadleveladditive is create a script that is to go on any gameobject that must persist between levels. In this script use

 DontDestroyOnLoad(gameObject);

Object.DontDestroyOnLoad