2026-06-19 UI, UI로직
This commit is contained in:
63
Assets/My project/Memory Scripts/UI/MemoryProgressPopupUI.cs
Normal file
63
Assets/My project/Memory Scripts/UI/MemoryProgressPopupUI.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user