- Home /
This question was
closed Apr 14, 2014 at 03:33 AM by
getyour411 for the following reason:
Duplicate Question
Question by
Ultitanius · Apr 14, 2014 at 03:28 AM ·
timer
Creating a Timer
In an assignment, I need to create a timer, and it's not so much that the timer doesn't work, but it doesn't display the numbers in the format I'd like. I'd like to restrict it to "ss:ff" but, it shows up as "s.fffff".
This is the code that I have so far:
using UnityEngine; using System.Collections;
public class timer : MonoBehaviour {
public bool running = true;
private float timeElapsed;
public TextMesh watchMesh;
public gateCollision TimeEnd;
private bool startTimer = false;
// Update is called once per frame
void Update () {
if (startTimer) {
timeElapsed += Time.deltaTime;
watchMesh.text = timeElapsed.ToString();
}
}
public void StartTimer(bool start)
{
startTimer = start;
}
}
Comment
Please search UA/Google for hundreds of examples on String.Format.
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Timer running down too quickly 1 Answer
how do I make a Time Based Score System? 1 Answer
Manage timer within connected players 1 Answer
,Pause/stop timer (waitforseconds) 1 Answer