question with multiple choise system
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user