In Unity3D, C # gets the game time and displays it in stopwatch format,
Using UnityEngine; using System. collections; using UnityEngine. UI; public class Timer: MonoBehaviour {int hour; int minute; int second; int millisecond; // float timeSpend = 0.0f; // display Text text_timeSpend in the time zone; // Use this for initializationvoid Start () {text_timeSpend = GetComponent <Text> ();} // Update is called once per framevoid Update () {timeSpend + = Time. deltaTime; GlobalSetting. timeSpent = timeSpend; hour = (int) timeSpend/3600; minute = (int) timeSpend-hour * 3600)/60; second = (int) timeSpend-hour * 3600-minute * 60; millisecond = (int) (timeSpend-(int) timeSpend) * 1000); text_timeSpend.text = string. format ("{0: D2 }:{ 1: D2 }:{ 2: D2 }. {3: D3} ", hour, minute, second, millisecond );}}
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.