From 1c10e953f87975b4f00cd35ab9851597017a3afc Mon Sep 17 00:00:00 2001 From: BOT Alex <44818698+MagicBOTAlex@users.noreply.github.com> Date: Sun, 4 Feb 2024 08:04:26 +0100 Subject: [PATCH] Tried to finish WaveUI --- Assets/Prefabs/UI/UI.prefab | 2 ++ Assets/Scripts/UI/WaveUI.cs | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Assets/Prefabs/UI/UI.prefab b/Assets/Prefabs/UI/UI.prefab index 98ba4ea..bb6c413 100644 --- a/Assets/Prefabs/UI/UI.prefab +++ b/Assets/Prefabs/UI/UI.prefab @@ -1359,8 +1359,10 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 84bc2d619ed39294a84a697578c0d3f6, type: 3} m_Name: m_EditorClassIdentifier: + spawner: {fileID: 0} slider: {fileID: 6134467867004299163} waveText: {fileID: 5636459425788774448} + waveTextDisplayTime: 3 --- !u!1 &7671763227494701576 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/UI/WaveUI.cs b/Assets/Scripts/UI/WaveUI.cs index 8f5e2fb..e12dc6b 100644 --- a/Assets/Scripts/UI/WaveUI.cs +++ b/Assets/Scripts/UI/WaveUI.cs @@ -13,7 +13,7 @@ public class WaveUI : MonoBehaviour private void Start() { - waveText.gameObject.SetActive(false); + waveText.color = new Color(1, 1, 1, 0); } int prevWave = 0; @@ -31,11 +31,24 @@ public class WaveUI : MonoBehaviour IEnumerator ShowWave() { - waveText.gameObject.SetActive(true); + Color color = new Color(1, 1, 1, 0); + while (color.a > 1) + { + waveText.color = color; + color.a += 0.05f; + yield return new WaitForSecondsRealtime(0.1f); + } + waveText.text = $"Wave: {spawner.Wave}"; yield return new WaitForSecondsRealtime(waveTextDisplayTime); - waveText.gameObject.SetActive(false); + color = new Color(1, 1, 1, 1); + while (color.a <= 0) + { + waveText.color = color; + color.a -= 0.05f; + yield return new WaitForSecondsRealtime(0.1f); + } } }