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; } }