using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UI; public class WaveUI : MonoBehaviour { [SerializeField] private EnemySpawner spawner; [SerializeField] private Slider slider; [SerializeField] private TMP_Text waveText; [SerializeField] private float waveTextDisplayTime = 3f; private void Start() { waveText.color = new Color(1, 1, 1, 0); } int prevWave = 0; private void Update() { float waveProgressTime = spawner.timer / spawner.WaveTime; slider.value = waveProgressTime; if (prevWave != spawner.Wave) { prevWave = spawner.Wave; StartCoroutine(ShowWave()); } } IEnumerator ShowWave() { waveText.text = $"Wave: {spawner.Wave}"; Color color = new Color(1, 1, 1, 0); while (color.a < 1) { color.a += 0.05f; waveText.color = color; yield return new WaitForSecondsRealtime(0.05f); } yield return new WaitForSecondsRealtime(waveTextDisplayTime); color = new Color(1, 1, 1, 1); while (color.a >= 0) { color.a -= 0.05f; waveText.color = color; yield return new WaitForSecondsRealtime(0.05f); } } }