48 lines
1.3 KiB
C#
48 lines
1.3 KiB
C#
using UnityEngine;
|
|
|
|
namespace OCTOPUS_TWIN
|
|
{
|
|
public class LocalPopupManager : MonoBehaviour
|
|
{
|
|
// 인스펙터에서 이 패널 안에 있는 Blocker 이미지 연결
|
|
[SerializeField] private GameObject blockerObj;
|
|
|
|
private int activePopupCount = 0;
|
|
|
|
private void OnEnable()
|
|
{
|
|
// 패널이 켜질 때 초기화 (혹시 꼬였을 경우를 대비)
|
|
activePopupCount = 0;
|
|
if (blockerObj != null) blockerObj.SetActive(false);
|
|
}
|
|
|
|
// 팝업들이 켜질 때 이 함수를 호출
|
|
public void RegisterPopupOpen()
|
|
{
|
|
activePopupCount++;
|
|
UpdateBlockerState();
|
|
}
|
|
|
|
// 팝업들이 꺼질 때 이 함수를 호출
|
|
public void RegisterPopupClose()
|
|
{
|
|
activePopupCount--;
|
|
if (activePopupCount < 0) activePopupCount = 0;
|
|
UpdateBlockerState();
|
|
}
|
|
|
|
private void UpdateBlockerState()
|
|
{
|
|
if (blockerObj == null) return;
|
|
|
|
// 팝업이 1개라도 있으면 블로커 켜기, 없으면 끄기
|
|
bool shouldShow = activePopupCount > 0;
|
|
|
|
// 상태가 다를 때만 SetActive 호출 (최적화)
|
|
if (blockerObj.activeSelf != shouldShow)
|
|
{
|
|
blockerObj.SetActive(shouldShow);
|
|
}
|
|
}
|
|
}
|
|
} |