Advertisement
CakeMeister

3d ball Timer

Aug 23rd, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.72 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. public class timer : MonoBehaviour {
  7.     public Text timertext;
  8.     private float time;
  9.     public bool pause = false;
  10.     // Use this for initialization
  11.     void Start () {
  12.         time = Time.time;
  13.     }
  14.    
  15.     // Update is called once per frame
  16.     void Update () {
  17.  
  18.         if (pause)
  19.             return;
  20.            
  21.         time += Time.deltaTime;
  22.         string minutes = ((int)time / 60).ToString();
  23.         string seconds = (time % 60).ToString("f1");
  24.         timertext.text = minutes + ":" + seconds;
  25.     }
  26.  
  27.     public void pausecolor()
  28.     {
  29.         pause = true;
  30.         timertext.color = Color.yellow;
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement