Question by
davide-aldegheri · Jun 28, 2016 at 09:20 AM ·
timetimertostring
Problem with a stopwatch
Hi everyone, I'm trying to create a stopwatch for an application i'm developing, I was able to make it work by using Time.deltaTime, but I'd like to use TimeSpan instead, but, I'm not able to make it work
Here's my code
currentTime += 1*Time.deltaTime;
var min : float = Mathf.Floor(currentTime/60);
var sec : float = Mathf.Floor(currentTime%60);
var elapsedToString : String = String.Format("{0:00}:{1:00}", min, sec);
Then I assign that string to my text component. This works, but how can I format it by using TimeSpan? I've tried different things to no avail. Of course it has to start from 0 always and show only the elapsed time, not the time of the day.
Have a nice day and thanks in advance!
Comment