- Home /
Offline timer
I want to make a countdown timer, which will count after the game is down.
public Text timerText;
private float startTime;
private bool timerFinished = false;
public float plusTime = 10f;
public float t;
void Start()
{
Load();
startTime = Time.time + plusTime;
}
public void Update()
{
plusTime = Time.time - 1;
if (timerFinished)
return;
float t = Time.time - startTime;
string minutes = ((int)-t / 60).ToString("0");
string seconds = (-t % 60).ToString("00");
timerText.text = "2x Production active for " + minutes + ":" + seconds;
if (t >= 0)
{
TimerStop();
}
Save();
}
public void TimerStop()
{
timerFinished = true;
}
public void Load()
{
plusTime = float.Parse(PlayerPrefs.GetString("plusTime", "10"));
}
public void Save()
{
PlayerPrefs.SetString("plusTime", plusTime.ToString());
}
Comment
Your answer

Follow this Question
Related Questions
countdown timer acivation 1 Answer
Coroutine Countdown Timer being extremely slow 1 Answer
Problem with countdown timer. 3 Answers
how to make a varied countdown timer 1 Answer
Timer doesn't work properly 2 Answers