Create "GameObject ==> UI ==> Text".
Attach below script to Canvas
Code :-
=====
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class timerScript : MonoBehaviour {
public Text TimerText;
public float countdownTime = 60 ;
// Update is called once per frame
void Update () {
countdownTime -= Time.deltaTime;
int minutes = Mathf.FloorToInt(countdownTime / 60F);
int seconds = Mathf.FloorToInt(countdownTime - minutes * 60);
string niceTime = string.Format("{0:0}:{1:00}", minutes, seconds);
TimerText.text = niceTime;
}
}
Attach below script to Canvas
Code :-
=====
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class timerScript : MonoBehaviour {
public Text TimerText;
public float countdownTime = 60 ;
// Update is called once per frame
void Update () {
countdownTime -= Time.deltaTime;
int minutes = Mathf.FloorToInt(countdownTime / 60F);
int seconds = Mathf.FloorToInt(countdownTime - minutes * 60);
string niceTime = string.Format("{0:0}:{1:00}", minutes, seconds);
TimerText.text = niceTime;
}
}
This comment has been removed by the author.
ReplyDeletePLEASE add Hour.
ReplyDeleteThanks for this.