usingUnityengine;usingSystem.Collections; Public classTime1:monobehaviour {floatTime =0; intMinutes,seconds,microseconds; //Public Gameobject Lab; //Use this for initialization voidStart () {//Lab = This.lab; } //Update is called once per frame voidUpdate () { time+=Time.deltatime; Minutes= ((int) time)/ -; Seconds= ((int)-(((int) time)/ -)* -; Microseconds= (int) (time* -)- (int) (time* -)/ -* -; if(minutes = =0 ) { if(Seconds = =0) { if(microseconds = =0) {Debug.Log ("00:00:00"); } if(microseconds>0&& microseconds<Ten) {Debug.Log ("00:00:0"+microseconds); } if(microseconds>9) {Debug.Log ("00:00:"+microseconds); } } if(Seconds >0&& seconds <Ten) { if(microseconds = =0) {Debug.Log ("00:0"+ seconds+": xx"); } if(Microseconds >0&& microseconds <Ten) {Debug.Log ("00:0"+ seconds+": 0"+microseconds); } if(Microseconds >9) {Debug.Log ("00:0"+ seconds+":"+microseconds); } } if(Seconds >9&& seconds < -) { if(microseconds==0) {Debug.Log ("XX:"+seconds+": xx"); } if(Microseconds >0&& microseconds <Ten) {Debug.Log ("XX:"+ seconds+": 0"+microseconds); } if(Microseconds >9) {Debug.Log ("XX:"+ seconds+":"+microseconds); } } } if(Minutes >0&& minutes <Ten) { if(Seconds = =0) { if(microseconds = =0) {Debug.Log ("0"+minutes+": 00:00"); } if(microseconds>0&& microseconds<Ten) {Debug.Log ("0"+ minutes +": 00:0"+microseconds); } if(Microseconds >9) {Debug.Log ("0"+minutes+": xx:"+microseconds); } } if(Seconds >0&& seconds <Ten) { if(microseconds = =0) {Debug.Log ("0"+minutes+": 0"+ seconds+": xx"); } if(Microseconds >0&& microseconds <Ten) {Debug.Log ("0"+minutes+": 0"+ seconds+": 0"+microseconds); } if(Microseconds >9) {Debug.Log ("0"+minutes+": 0"+ seconds+":"+microseconds); } } if(Seconds >9&& seconds < -) { if(microseconds = =0) {Debug.Log ("0"+minutes+":"+seconds+": xx"); } if(microseconds>0&& microseconds<Ten) {Debug.Log ("0"+minutes+":"+seconds+": 0"+microseconds); } if(Microseconds >9) {Debug.Log ("0"+minutes+":"+seconds+":"+microseconds); } } } if(minutes>9) { if(Seconds = =0) { if(microseconds = =0) {Debug.Log (minutes+": 00:00"); } if(microseconds>0&& microseconds<Ten) {Debug.Log (minutes+": 00:0"+microseconds); } if(Microseconds >9) {Debug.Log (minutes+": xx:"+microseconds); } } if(Seconds >0&& seconds <Ten) { if(microseconds = =0) {Debug.Log (minutes+": 0"+ seconds+": xx"); } if(Microseconds >0&& microseconds <Ten) {Debug.Log (minutes+": 0"+ seconds+": 0"+microseconds); } if(Microseconds >9) {Debug.Log (minutes+": 0"+ seconds+":"+microseconds); } } if(Seconds >9&& seconds < -) { if(microseconds = =0) {Debug.Log (minutes+":"+seconds+": xx"); } if(microseconds>0&& microseconds<Ten) {Debug.Log (minutes+":"+seconds+": 0"+microseconds); } if(Microseconds >9) {Debug.Log (minutes+":"+seconds+":"+microseconds); } } } } }
Unity3d in C # gets the game time and displays the stopwatch format