rabidus-test/Assets/Scripts/TimerText.cs

32 lines
655 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(TMPro.TextMeshProUGUI))]
public class TimerText : MonoBehaviour
{
private vTimerCounter _timer;
private TMPro.TextMeshProUGUI _text;
private void Awake()
{
_timer = FindObjectOfType<vTimerCounter>();
_text = GetComponent<TMPro.TextMeshProUGUI>();
}
private void OnEnable()
{
_timer.OnUpdateTimer += UpdateText;
}
private void OnDisable()
{
_timer.OnUpdateTimer -= UpdateText;
}
private void UpdateText(string text)
{
_text.SetText(text);
}
}