Can you help me how to assign the initial data to the game. I used the PlayerPrefs.GetInt, SetInt class, in the game. But when calling it in start function or wake function, when game starts, it set the data again. Can you help me how to only call this function once when installing the game. Or how to assign data when installing the game. Thank you!
CodePudding user response:
When game awake, load PlayerPrefs with default value and write back PlayerPrefs to make sure data initialized.
private void Awake()
{
int defaultValue = 123;
int data = PlayerPrefs.GetInt("some_data", defaultValue );
PlayerPrefs.SetInt("some_data", data);
}
