summaryrefslogtreecommitdiff
path: root/GameCode/TextFlicker.cs
blob: e710a431a0b96eb98d82f0eb9c506448d6af4c75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using TMPro;
using UnityEngine;

public class TextFlicker : MonoBehaviour
{
	public string[] strings;

	public float rate = 0.2f;

	private float counter;

	private int currentID;

	private TextMeshProUGUI text;

	private void Start()
	{
		text = GetComponent<TextMeshProUGUI>();
	}

	private void Update()
	{
		counter += Time.deltaTime;
		if (counter > rate)
		{
			counter = 0f;
			currentID++;
			if (currentID >= strings.Length)
			{
				currentID = 0;
			}
			text.text = strings[currentID];
		}
	}
}