Hi,
I'm currently working on a endless runner game and im struggling with my high score. I have a timer script that works just fine, but I want to able to save the highest score using playerprefs. Does anyone have a clue on how I can do this?
Here's my current timer script:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Timer : MonoBehaviour {
public Text timer;
public float highscore = 0;
public float seconds = 00;
public float miliseconds = 00;
static public float minutes = 00;
public Canvas canvas;
void FixedUpdate(){
if (miliseconds >= 60) {
seconds++;
miliseconds = 00;
}
if (seconds >=60) {
minutes++;
seconds = 00;
}
if (GameOver.gameover == false) {
miliseconds += Time.deltaTime * 60;
}
timer.text = minutes.ToString ("00") + ":" + seconds.ToString ("00") + ":" + miliseconds.ToString ("00");
}
}
↧