Files
WhaleAdventure_VR/Assets/My project/Memory Scripts/UI/MemoryProgressPopupUI.cs
skrwns304@gmail.com b1e85a5b89 2026-06-19 UI, UI로직
2026-06-19 14:27:40 +09:00

64 lines
1.4 KiB
C#

using System.Collections;
using TMPro;
using UnityEngine;
public class MemoryProgressPopupUI : MonoBehaviour
{
[Header("Panel")]
[SerializeField] private GameObject popupPanel;
[Header("Text")]
[SerializeField] private TMP_Text titleText;
[SerializeField] private TMP_Text countText;
[Header("Settings")]
[SerializeField] private string message = "기억의 조각을 얻었다!";
[SerializeField] private float showTime = 1.5f;
private Coroutine popupRoutine;
private void Awake()
{
HidePopup();
}
public void ShowPopup(int current, int max)
{
if (popupRoutine != null)
StopCoroutine(popupRoutine);
popupRoutine = StartCoroutine(PopupRoutine(current, max));
}
public void HidePopup()
{
if (popupRoutine != null)
{
StopCoroutine(popupRoutine);
popupRoutine = null;
}
if (popupPanel != null)
popupPanel.SetActive(false);
}
private IEnumerator PopupRoutine(int current, int max)
{
if (popupPanel != null)
popupPanel.SetActive(true);
if (titleText != null)
titleText.text = message;
if (countText != null)
countText.text = $"{current} / {max}";
yield return new WaitForSeconds(showTime);
if (popupPanel != null)
popupPanel.SetActive(false);
popupRoutine = null;
}
}