Files
SimUL/Assets/Scripts/QuestionDialogUI.cs
T
2022-08-17 11:14:32 +03:00

49 lines
997 B
C#

using System;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class QuestionDialogUI : MonoBehaviour
{
//public static QuestionDialogUI Instance { get; private set; }
[SerializeField]
private TextMeshProUGUI _textMeshPro;
[SerializeField]
private Button _yesBtn;
[SerializeField]
private Button _noBtn;
private void Awake()
{
// Instance = this;
ShowQuestion("Are you sure ?", () =>
{
Debug.Log("Yes");
}, () =>
{
Debug.Log("No");
});
}
public void ShowQuestion(string questionText, Action yesAction, Action noAction)
{
_textMeshPro.text = questionText;
_yesBtn.onClick.AddListener(() =>
{
Hide();
yesAction();
});
_noBtn.onClick.AddListener(() =>
{
Hide();
noAction();
});
}
private void Hide()
{
gameObject.SetActive(false);
}
}