1 using UnityEngine; 2 using UnityEngine.UI; 3 4 public class Text : MonoBehaviour { 5 6 public Text t; 7 private float rate = 2f; 8 private float lastTime = 0; 9 10 // Use this for initialization 11 void Start () { 12 13 Random.InitState(System.Guid.NewGuid().GetHashCode()); 14 15 } 16 17 // Update is called once per frame 18 void Update () { 19 float time = Time.time; 20 if(time - lastTime > rate) 21 { 22 lastTime = time; 23 Text(); 24 } 25 } 26 27 28 public void Text() 29 { 30 int random = Random.Range(20, 60); 31 t.text = random; 32 } 33 }