- Home /
Start between scenes.
Hello, Is any solution how to set variables only on gamestart? I am making RPG game, and when i get into shop (separated scene), and back all variables set back on Start() function value...
void Start() { PlayerPrefs.SetInt ("FreePod1", 1); PlayerPrefs.SetInt ("FreePod2", 1); PlayerPrefs.SetString ("Sword1Name", "Nothing"); PlayerPrefs.SetString ("Sward2Name", "Nothing"); }
}
Comment
Best Answer
Answer by Dave-Carlile · Sep 15, 2015 at 02:08 PM
You can create another player prefs values that determines whether or not you should intialize the values.
So your Start would look something like...
void Start()
{
// if the KeepValues key exists then don't reset the other values
if (PlayerPrefs.HasKey("KeepValues")) return;
PlayerPrefs.SetInt("FreePod1", 1);
...
}
When starting a new game or whatever you'll need to delete the KeepValues key so everything will initialize.
Your answer
Follow this Question
Related Questions
Initialising List array for use in a custom Editor 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Death Counter Resets When Reloading Scene. 3 Answers
Fading To New Scene Problem? 1 Answer