So I've been struggling with some script for a long time and I can't figure it out I have 2 scripts on diferent scenes the first one in the menu : Code (JavaScript): var EasyLevelReached_1 : int = 0; EasyLevelReached_1 = PlayerPrefs.GetInt("SavedEasyLevel1"); function showUnlocked () { if(EasyLevelReached_1 == 1){ print("Level 1 was finished"); } } and the second one in the first level function OnTriggerEnter (){ PlayerPrefs.SetInt("SavedEasyLevel1", 1); Debug.Log("SavedLevel = 1"); yield WaitForSeconds(2.0); // wait for 5 Application.LoadLevel("Menu"); } I can't figure it out why I can't save the SavedEasyLevel1 so after I go back into the menu my SavedEasyLevel1 it's still 0 not 1
This. Code formatting and readability goes out the window without code tags. Help us to help you! As for the problem, you're missing a call to Save to actually commit the things you're trying to save.
So i put the save and still not working: Code (JavaScript): function OnTriggerEnter (){ PlayerPrefs.SetInt("SavedEasyLevel1", 1); Debug.Log("SavedLevel = 1"); yield WaitForSeconds(2.0); // wait for 5 Application.LoadLevel("Menu"); PlayerPrefs.Save(); } When I call showUnlocked() the EasyLevelReached_1 is still 0.