OneShotOneKill/Assets/Script/Info/Popup.cs

56 lines
1.1 KiB
C#

using System;
using TMPro;
using UnityEngine;
public enum ePopupType { One, Two, Check }
public class Popup : MonoBehaviourSingletonTemplate<Popup>
{
public TextMeshProUGUI label_msg;
Action m_ok, m_no;
public void Set(ePopupType _btn, int _msgkey, Action _ok = null, Action _no = null)
{
m_ok = _ok;
m_no = _no;
On();
label_msg.text = table_localtext.Ins.Get_Text(_msgkey);
}
public void Set(ePopupType _btn, int _msgkey, Action _ok = null, Action _no = null, params object[] args)
{
m_ok = _ok;
m_no = _no;
On();
label_msg.text = DSUtil.Format(_msgkey, args);
}
public void Set(string msg, Action ok = null, Action no = null)
{
m_ok = ok;
m_no = no;
On();
label_msg.text = msg;
}
public void Set_QuitPopup()
{
Set(ePopupType.Two, 22, () => { DSUtil.Quit(); });
}
public void OnClick_OK()
{
Off();
m_ok?.Invoke();
}
public void OnClick_No()
{
Off();
m_no?.Invoke();
}
}