Shamba

perc_calc

Apr 22nd, 2018
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.69 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using TMPro;
  6.  
  7. public class perc_calc : MonoBehaviour {
  8.  
  9.     public AudioSource _audio;
  10.     private float length;
  11.     private float CurrentTime;
  12.     public Text DisplayUI;
  13.     public TextMeshProUGUI perc_text;
  14.     // Use this for initialization
  15.     void Start()
  16.     {
  17.  
  18.     }
  19.  
  20.     // Update is called once per frame
  21.     void Update()
  22.     {
  23.         length = _audio.clip.length;
  24.         CurrentTime = _audio.time;
  25.         DisplayUI.text = ((CurrentTime / length) * 100).ToString("0") + "%";
  26.         perc_text.text = ((CurrentTime / length) * 100).ToString("0") + "%";
  27.     }
  28. }
Add Comment
Please, Sign In to add comment