Using unityengine;using system.collections;using Unityengine.ui;public class Timer:monobehaviour { int hour; int minute; int second; int millisecond; The time already spent float timespend = 0.0f; Displays the text of the time area text_timespend;//use the this for initializationvoid Start () { text_timespend = getcomponent<t Ext> ();} Update is called once per framevoid update () { timespend + = Time.deltatime; Globalsetting.timespent = Timespend; hour = (int) timespend/3600; minute = ((int) timespend-hour * 3600)/; second = (int) timespend-hour * 3600-minute *; millisecond = (int) ((Timespend-(int) timespend) * +); Text_timespend.text = string. Format ("{0:d2}:{1:d2}:{2:d2}.{ 3:D3} ", hour, minute, second, millisecond);}}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Unity3d in C # gets the game time and displays the stopwatch format