I am currently working on a menu for my game, and the sound options screen works for the game, however I would like to have the sound values saved for the next time a player starts the game, instead of them having to change the sound slider everytime.
Currently, I have the sliders set up like this:
static var musicVolume: float = 100;
var master : float = 100;
var minSound : float = 0;
var maxSound : float = 100;
function Sound()
{
//GUILayout variables not related to topic
GUILayout.BeginArea(Rect(hPosition, vPosition, buttonWidth, 600));
//sliders
GUILayout.Label("Master");
master = GUILayout.Horizontal (master, minSound, maxSound);
musicVolume = GUILayout.HorizontalSlider(musicVolume, minSound, maxSound);
if(GUILayout.Button("Back to Options")
{
PlayerPrefs.SetFloat("Master", master);
PlayerPrefs.SetFloat("Music", musicVolume);
GUILayout.EndArea()
}
There are a few others things, executing Sound() etc.
----------
My question is: I have the volume values being saved when the user clicks "Back to Options". However, how would it be possible to load the values onto the sliders after the user closes and opens the game later?
----------
↧