I have a question about playerprefs on my android mobile game not initializing properly. I have already pre-set my playerprefs data on a variable with a value of 3. In my play mode on unity the value is showing 3 through the textmesh that I have it scripted on. But when I install and test it on my android mobile device it is 0. can someone help how to properly initialize my playerprefs data to the right value on android platform?
public static Game GM;
int maxAntiBody;
public TextMeshProUGUI antibodyTexMesh;
void Start () {
if (GM == null)
{
GM = this;
}
maxAntiBody = PlayerPrefs.GetInt("MaxAntiBody");
antibodyTexMesh.text = maxAntibody.toString();
}
void Update () {
debugging();
}
//I use this method for setting or resetting my desired value for the playerprefs data I'm working with. In this case I choose 3 as a value.
void debugging() {
if (Input.GetKeyDown(KeyCode.M))
{
PlayerPrefs.SetInt("MaxAntiBody", plus++);
Debug.Log("max anti body value is : " + PlayerPrefs.GetInt("MaxAntiBody"));
}
else if (Input.GetKeyDown(KeyCode.R))
{
plus = 0;
PlayerPrefs.SetInt("MaxAntiBody", plus);
Debug.Log("max anti body is now reseted to : " + PlayerPrefs.GetInt("MaxAntiBody"));
}
}
3
when the game is first run on a new device? \$\endgroup\$