Neg_Utils/NEG/UI/Popup/MonoPopup.cs

24 lines
598 B
C#

using NEG.UI.Area;
using System;
using UnityEngine;
namespace NEG.UI.Popup
{
public class MonoPopup : MonoBehaviour, IPopup
{
public event Action<IPopup> OnPopupClosed;
public bool IsValid { get; private set; }
public void Close(bool isForced = false)
{
IsValid = false;
gameObject.SetActive(false);
if(!isForced)
OnPopupClosed?.Invoke(this);
}
public void SetEnabled(bool setEnabled) => gameObject.SetActive(setEnabled);
void IPopup.Show() => IsValid = true;
}
}