- Home /
Android and PlayerPrefs.Save
Simple question! Does PlayerPrefs.Save work on Android devices?
Comment
Answer by Omega2077 · Nov 11, 2015 at 01:23 PM
Question? How would I get my code here to save my highscore int with PlayerPrefs.Save
using UnityEngine;
using System.Collections;
public class Score : MonoBehaviour {
static int score = 0;
static int highScore = 0;
static public void AddPoint() {
score++;
if(score > highScore) {
highScore = score;
}
}
void Start() {
highScore = PlayerPrefs.GetInt ("highScore", 0);
}
void OnDestroy() {
PlayerPrefs.SetInt ("highScore", highScore);
}
void Update () {
GetComponent<GUIText> ().text = "Score: " + score + "\nHigh Score: " + highScore;
}
}