I use this script in 3d Text it works, but i want to set clock for example it’ll starts at 00:00:00 how can i do this ? this is the my script thanks a lot.
var date : System.DateTime;
//sets something allowing you to populate it with the date and time
private var text : String;
function Update()
{
//tells the var to look for the precise moment you are at
var date = System.DateTime.Now;
//converts the above var to a readable string
text = date.ToString("HH:mm:ss");
//prints it to inspector
GetComponent(TextMesh).text = text;
}
Store a “start time” and subtract it from the “current time”, this will give you a timespan of the elapsed time. Call the Reset function to start back at 00:00:00.
var date : System.DateTime;
//sets something allowing you to populate it with the date and time
private var text : String;
var startDateTime : System.DateTime;
function Start()
{
Reset();
}
public function Reset()
{
startDateTime = System.DateTime.Now;
}
function Update()
{
//tells the var to look for the precise moment you are at
var date = System.DateTime.Now;
//converts the above var to a readable string
//text = date.ToString("HH:mm:ss");
// calculate the timespan between the start time and current time
var timespan : System.TimeSpan = date - startDateTime;
text = String.Format("{0}:{1}:{2}",
timespan.Hours.ToString("00"),
timespan.Minutes.ToString("00"),
timespan.Seconds.ToString("00"));
//prints it to inspector
GetComponent(TextMesh).text = text;
}