- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class Timer : MonoBehaviour {
- public Text timerText;
- public AudioClip TimerMusic;
- private AudioSource MediaTimerMusic;
- private float startTime;
- // Use this for initialization
- void Start () {
- startTime = Time.time;
- MediaTimerMusic = gameObject.AddComponent<AudioSource>();
- MediaTimerMusic.clip = TimerMusic;
- }
- // Update is called once per frame
- void Update () {
- float t = Time.time - startTime;
- string minutes = ((int)t / 60).ToString();
- string seconds = (t % 60).ToString("f2");
- timerText.text = minutes + ":" + seconds;
- //MediaTimerMusic.Play();
- }
- }
[text] Timer
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Editor
You can edit this paste and save as new: