45 lines
886 B
C#
45 lines
886 B
C#
|
|
using System;
|
|
using TMPro;
|
|
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class YesNoDialogUI : MonoBehaviour
|
|
{
|
|
public static YesNoDialogUI Instance { get; private set; }
|
|
|
|
[SerializeField]
|
|
private TextMeshProUGUI _textMeshPro;
|
|
[SerializeField]
|
|
private Button _yesBtn;
|
|
[SerializeField]
|
|
private Button _noBtn;
|
|
private void Awake()
|
|
{
|
|
Instance = this;
|
|
Hide();
|
|
}
|
|
|
|
public void ShowQuestion(string questionText, Action yesAction, Action noAction)
|
|
{
|
|
_textMeshPro.text = questionText;
|
|
_yesBtn.onClick.AddListener(() =>
|
|
{
|
|
Hide();
|
|
yesAction();
|
|
});
|
|
_noBtn.onClick.AddListener(() =>
|
|
{
|
|
Hide();
|
|
noAction();
|
|
});
|
|
gameObject.SetActive(true);
|
|
}
|
|
|
|
private void Hide()
|
|
{
|
|
gameObject.SetActive(false);
|
|
}
|
|
}
|