game(scripts): standardise CanvasFade
This commit is contained in:
parent
e4b5522992
commit
337e022356
1 changed files with 15 additions and 16 deletions
|
@ -1,32 +1,32 @@
|
||||||
/*
|
/*
|
||||||
Author : Wai Lam
|
* Author: Wai Lam
|
||||||
Date : 13/2/2025
|
* Date: 13/2/2025
|
||||||
Description : Counting days
|
* Description: Counting days
|
||||||
*/
|
*/
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.SceneManagement;
|
|
||||||
using TMPro;
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
public class CanvasFade : MonoBehaviour
|
public class CanvasFade : MonoBehaviour
|
||||||
{
|
{
|
||||||
public CanvasGroup dayPanel; // Assign the UI Panel
|
public CanvasGroup dayPanel; // Assign the UI Panel
|
||||||
public TextMeshProUGUI dayText; // Assign the TextMeshPro UI
|
public TextMeshProUGUI dayText; // Assign the TextMeshPro UI
|
||||||
|
|
||||||
public static event Action OnDayPanelHidden;
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
if (GameManager.Instance != null)
|
if (GameManager.Instance != null)
|
||||||
{
|
{
|
||||||
int dayNumber = GameManager.Instance.currentDay;
|
var dayNumber = GameManager.Instance.currentDay;
|
||||||
dayText.text = "Day " + dayNumber;
|
dayText.text = "Day " + dayNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
StartCoroutine(FadeOutPanel());
|
StartCoroutine(FadeOutPanel());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static event Action OnDayPanelHidden;
|
||||||
|
|
||||||
private IEnumerator FadeOutPanel()
|
private IEnumerator FadeOutPanel()
|
||||||
{
|
{
|
||||||
dayPanel.alpha = 1f;
|
dayPanel.alpha = 1f;
|
||||||
|
@ -34,8 +34,8 @@ public class CanvasFade : MonoBehaviour
|
||||||
|
|
||||||
yield return new WaitForSeconds(3f); // Display for 3 seconds
|
yield return new WaitForSeconds(3f); // Display for 3 seconds
|
||||||
|
|
||||||
float fadeDuration = 1.5f;
|
const float fadeDuration = 1.5f;
|
||||||
float elapsedTime = 0f;
|
var elapsedTime = 0f;
|
||||||
|
|
||||||
while (elapsedTime < fadeDuration)
|
while (elapsedTime < fadeDuration)
|
||||||
{
|
{
|
||||||
|
@ -45,8 +45,7 @@ public class CanvasFade : MonoBehaviour
|
||||||
}
|
}
|
||||||
|
|
||||||
dayPanel.gameObject.SetActive(false);
|
dayPanel.gameObject.SetActive(false);
|
||||||
|
|
||||||
OnDayPanelHidden?.Invoke();
|
|
||||||
|
|
||||||
|
OnDayPanelHidden?.Invoke();
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue