Both the state for the music and sound ( on / off) save but only the music seems to load? The code is almost identical for both parts so I dont understand why one works and the other doesn't. All the refrences are correctly setup too.
//edit After playing around with this for a while I seem to have flipped it so now the sound loads but the music does not. But the code seems exactly the same?
//edit 2: it seems to be the first option I select - sound or music, whichever I select first will work with that iPhone build and the other wont?
var musicToggle : UIStateToggleBtn;
var soundToggle : UIStateToggleBtn;
function Start()
{
// Load our music settings if they exist.
if (PlayerPrefs.HasKey("MusicSettings"))
{
// Loads the points and puts it into this variable.
var previousMusicSetting = PlayerPrefs.GetString ("MusicSettings");
musicToggle.SetToggleState(previousMusicSetting);
}
else
{
// Set a preference file called "MusicSettings" with an intial value of On.
PlayerPrefs.SetString ("MusicSettings", "On" );
musicToggle.SetToggleState("On");
}
// Do the same for our sound settings.
if (PlayerPrefs.HasKey("SoundSettings"))
{
// Loads the sound on/off setting puts it into this variable.
var previousSoundSetting = PlayerPrefs.GetString ("SoundSettings");
soundToggle.SetToggleState(previousSoundSetting);
}
else
{
// Set a preference file called "SoundSettings" with an intial value of On.
PlayerPrefs.SetString ("SoundSettings", "On" );
soundToggle.SetToggleState("On");
}
}
function MusicToggle()
{
if(musicToggle.StateName == "On")
{
PlayerPrefs.SetString ("MusicSettings", "On" );
//Debug.Log(PlayerPrefs.GetString("MusicSettings")); /// Debugs show prefs are being saved.
}
else
{
PlayerPrefs.SetString ("MusicSettings", "Off" );
//Debug.Log(PlayerPrefs.GetString("MusicSettings"));
}
}
function SoundToggle()
{
if(soundToggle.StateName == "On")
{
PlayerPrefs.SetString ("SoundSettings", "On" );
}
else
{
PlayerPrefs.SetString ("SoundSettings", "Off" );
}
}