30 lines
593 B
C#
30 lines
593 B
C#
using TMPro;
|
|
using UnityEngine;
|
|
|
|
[RequireComponent(typeof(TMP_Text))]
|
|
public class LoadingTextTMP : MonoBehaviour
|
|
{
|
|
public string baseText = "Loading";
|
|
public char dotChar = '.';
|
|
public int dotCount =3;
|
|
public float interval = 1f;
|
|
TMP_Text txt;
|
|
void Start()
|
|
{
|
|
txt = GetComponent<TMP_Text>();
|
|
}
|
|
|
|
|
|
float timer = 0;
|
|
void Update(){
|
|
timer += Time.deltaTime;
|
|
if(timer > interval * dotCount){
|
|
timer =0;
|
|
}
|
|
|
|
int dots = (int)(timer / interval);
|
|
|
|
txt.text = baseText + new string(dotChar, dots);
|
|
}
|
|
}
|