PlayerPrefs not working on android
Hey, I managed to add a score and a highscore counter to my android app. Everything went fine and worked good in Unity. I build my app and wanted to test it on my phone but the highscore counter, which is saved using PlayerPrefs wont show... There are many ways out there but nothing worked :( any ideas ?
Here is my code
public class Score : MonoBehaviour {
public Transform Charakter;
public Text scoreText;
public Text HighscoreText;
public void Start()
{
HighscoreText.text = PlayerPrefs.GetString("HighScore");
PlayerPrefs.Save();
}
private void Update()
{
scoreText.text = Charakter.position.x.ToString("0");
int score = int.Parse(scoreText.text);
int highscore = int.Parse(PlayerPrefs.GetString("HighScore"));
if (score > highscore)
{
PlayerPrefs.SetString("HighScore", scoreText.text);
PlayerPrefs.Save();
}
}
}
Answer by Cuttlas-U · Mar 01, 2018 at 09:20 AM
hey; try remove this lane : PlayerPrefs.Save();
its not needed;
any thing else is ok on your code and i dont see any problems;
Your answer
Follow this Question
Related Questions
Game working in pc but not in Android While Testing 0 Answers
Data not Saving in Android Using Unity Persistance Saving Training. 1 Answer
MouseButtonUp not always called 1 Answer
Android persistentdatapath Can be read but not written. 0 Answers
How do I make my player's movement relative to Main Camera's direction? 1 Answer