Logo my studio is game, portfólio is developer game

Creating a time count of minutes, seconds, and milliseconds in Unity

This script makes the count of time in minutes, secondsand milliseconds in Unity. 

using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class timer : MonoBehaviour {

  public float min, sec, fraction;

  public float timecount, starttime;

  string textMold = "{00:00}:{1:00}:{2:00}";

  string textFormat;

  [SerializeField] private Text GUIText;

  void Start () {
    starttime = Time.time;

  void Update () {
    timecount = Time.time - starttime;
    min = (timecount / 60f);
    sec = (timecount % 60f);
    fraction = ((timecount * 10) % 10);
    textFormat = string.Format(textMold, min, sec, fraction);
    GUIText.text = textFormat.ToString();


Make contact!

Did you like this content? Let's talk...

I'm a game developer, I use unity. If you want to develop something, tell me!