Question by
mr.aleem001 · Mar 20, 2016 at 06:54 AM ·
c#texturetimetimerhighscores
I make a timing score script in unity 2D, how i make high score of time?? Script is as follow:
using UnityEngine; using System.Collections;
public class Timer : MonoBehaviour { float timer = 0;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
timer += Time.deltaTime;
}
void OnGUI () {
if (timer > 0) {
GUI.Label (new Rect (400, 10, 120, 50), "Score :" +(int)timer);
}
}
}
Comment
Answer by Ali-hatem · Mar 20, 2016 at 05:05 PM
you have to save data in order to read the old score & current score so you can tell because when reload scene every thing will reset see the doc save
& load but how to just make another variable to compare score :
float timer = 0;
float highscore;
void Update () {
timer += Time.deltaTime;
if(timer > highscore)
highscore = timer;
}
Your answer
Follow this Question
Related Questions
Save Timer HighScore 2 Answers
why the Timer isn't working 0 Answers
How do I add my Timer to my Score system in C# ? 0 Answers
Highscore - BestTime 1 Answer
"Object reference not set to the instance of an object" 0 Answers