47 lines
1.1 KiB
C#
47 lines
1.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace Beyond {
|
|
|
|
public class ModalPopup : MonoBehaviour
|
|
{
|
|
private static ModalPopup s_instance;
|
|
public static ModalPopup Instance => s_instance;
|
|
//public UnityAction<bool> m_onYesNo;
|
|
public delegate void OnYesNo(bool yes);
|
|
private OnYesNo m_handler;
|
|
private void Awake()
|
|
{
|
|
if (s_instance == null)
|
|
{
|
|
s_instance = this;
|
|
gameObject.SetActive(false);
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError("ModalPopup already exists!");
|
|
Destroy(this);
|
|
}
|
|
|
|
}
|
|
|
|
public void Show(OnYesNo handler)
|
|
{
|
|
m_handler = handler;
|
|
gameObject.SetActive(true);
|
|
}
|
|
public void OnYes()
|
|
{
|
|
m_handler(true);
|
|
gameObject.SetActive(false);
|
|
}
|
|
|
|
public void OnNo()
|
|
{
|
|
m_handler(false);
|
|
gameObject.SetActive(false);
|
|
}
|
|
|
|
}
|
|
} |