44 lines
1.0 KiB
C#
44 lines
1.0 KiB
C#
using UnityEngine;
|
|
|
|
namespace EnglewoodLAB
|
|
{
|
|
public class PopupBlocker : MonoBehaviour
|
|
{
|
|
public static PopupBlocker Instance { get; private set; }
|
|
|
|
private int activePopupCount = 0; // 현재 켜진 팝업 개수
|
|
|
|
private void Awake()
|
|
{
|
|
// 싱글톤 세팅
|
|
if (Instance == null) Instance = this;
|
|
else Destroy(gameObject);
|
|
|
|
// 시작할 때는 무조건 꺼두기
|
|
gameObject.SetActive(false);
|
|
activePopupCount = 0;
|
|
}
|
|
|
|
// 팝업이 켜질 때 호출
|
|
public void Show()
|
|
{
|
|
activePopupCount++;
|
|
gameObject.SetActive(true);
|
|
}
|
|
|
|
// 팝업이 꺼질 때 호출
|
|
public void Hide()
|
|
{
|
|
activePopupCount--;
|
|
|
|
// 음수가 되지 않도록
|
|
if (activePopupCount < 0) activePopupCount = 0;
|
|
|
|
// 켜진 팝업이 하나도 없을 때만 Blocker를 끔
|
|
if (activePopupCount == 0)
|
|
{
|
|
gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
} |