- Home /
How do I add used Time in scoreboard
Hi,
I am trying to add used time to scoreboard. When person perss pause button, timer stops. I can see used time in my game but I dont know how to add it in scoreboard. I know how to add score and player name but I have problem with used time. In c# script below I add username and score to scoreboard. I tried to add used time same way as I add username to scoreboard. It does not work. How can I reach used time? string does not seem to work.
using UnityEngine; using System.Collections;
public class Game : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetMouseButtonDown(0)) {
string username = SaveInputField.NimiTeksti.text;
int score = ScoreManager.score;
for (int i = 0; i < Random.Range(5,10); i ++){
}
Highscores.AddNewHighscore(username,score);
}
}
}
using UnityEngine; using System.Collections; using UnityEngine.UI;
public class Timer : MonoBehaviour {
public Text timerText;
private float startTime;
void Start () {
startTime = Time.time;
}
void Update (){
float t = Time.time - startTime;
string minutes = ((int)t / 60).ToString ();
string seconds = (t % 60).ToString ("f0");
timerText.text = minutes + ":" + seconds;
}
public void Finnish()
{
}
}
Your answer
Follow this Question
Related Questions
Miss a target and add to timer 1 Answer
Scoring System/Clock? 4 Answers
How to set lap timer for network multiplayer 0 Answers
How can i link my code together so the score value affects the timer value 1 Answer
3 star time base system 0 Answers