Files

49 lines
1.1 KiB
C#
Raw Permalink Normal View History

using TMPro;
using UnityEngine;
namespace UI
{
public class WaitStartUI : MonoBehaviour
{
public TMP_Text text;
public string baseText;
public int dotCount = 3;
public int dotCounter;
public float updateTime = 1;
private float timer;
private void Awake()
{
gameObject.SetActive(true);
}
private void Start()
{
if (string.IsNullOrEmpty(baseText))
baseText = text.text;
else
text.text = baseText;
}
private void Update()
{
timer += Time.deltaTime;
if (timer >= updateTime)
{
timer -= updateTime;
var dots = "";
for (var i = 0; i < dotCounter; i++) dots += ".";
text.text = baseText + dots;
dotCounter += 1;
if (dotCounter > dotCount) dotCounter = 0;
}
}
public void Hide()
{
gameObject.SetActive(false);
}
}
}