- Home /
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
Answer by Seizure · Sep 23, 2013 at 03:07 PM
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);
Your answer

Follow this Question
Related Questions
Saving changes a player has made to the world?!?!? 2 Answers
Horizontal Slider with Labels 3 Answers
Sensitivity slider using Easy touch 5 asset? 0 Answers
How to add the option to change field of view through using a slider in a game option menu? 1 Answer
Saving a UI Text Number Multiple Times 2 Answers