Advertisement
bvang

Distance Prototype

Sep 24th, 2017
459
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.63 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using TMPro;
  5.  
  6. public class TextMeshTimer : MonoBehaviour {
  7.  
  8.     public float startingTime;
  9.     private Texture theText;
  10.  
  11.     private TextMeshPro m_Text;
  12.  
  13.     // Use this for initialization
  14.     void Start () {
  15.         m_Text = GetComponent<TextMeshPro>();
  16.     }
  17.    
  18.     // Update is called once per frame
  19.     void Update () {
  20.        
  21.         // Subtract Timer to 0
  22.         startingTime -= Time.deltaTime;
  23.         m_Text.text = "" + Mathf.Round(startingTime) + "ft";
  24.  
  25.         // If the timer is 0, keep the timer displayed as 0.
  26.         if (startingTime <= 0) {
  27.  
  28.             m_Text.text = "0ft";
  29.         }
  30.        
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement