When the timer counts down below 10 seconds it drops the leading zero and just goes down to one number. I am wanting it to to say like "09"“08” exc exc.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Timer : MonoBehaviour {
public TextMesh timer;
float minutes = 5;
float seconds = 0;
float miliseconds = 0;
void Update()
{
if (miliseconds <= 0)
{
if (seconds <= 0)
{
minutes--;
seconds = 59;
}
else if (seconds >= 0)
{
seconds--;
}
miliseconds = 100;
}
miliseconds -= Time.deltaTime * 100;
//Debug.Log(string.Format("{0}:{1}:{2}", minutes, seconds);
timer.text = string.Format("{0}:{1}", minutes, seconds);
}
}