finish yes/no dialog with test

This commit is contained in:
voffka81
2022-08-17 11:28:10 +03:00
parent c0ea0addcb
commit 34fd8ec609
3 changed files with 38 additions and 9 deletions
+4 -9
View File
@@ -6,7 +6,7 @@ using UnityEngine.UI;
public class QuestionDialogUI : MonoBehaviour public class QuestionDialogUI : MonoBehaviour
{ {
//public static QuestionDialogUI Instance { get; private set; } public static QuestionDialogUI Instance { get; private set; }
[SerializeField] [SerializeField]
private TextMeshProUGUI _textMeshPro; private TextMeshProUGUI _textMeshPro;
@@ -16,14 +16,8 @@ public class QuestionDialogUI : MonoBehaviour
private Button _noBtn; private Button _noBtn;
private void Awake() private void Awake()
{ {
// Instance = this; Instance = this;
ShowQuestion("Are you sure ?", () => Hide();
{
Debug.Log("Yes");
}, () =>
{
Debug.Log("No");
});
} }
public void ShowQuestion(string questionText, Action yesAction, Action noAction) public void ShowQuestion(string questionText, Action yesAction, Action noAction)
@@ -39,6 +33,7 @@ public class QuestionDialogUI : MonoBehaviour
Hide(); Hide();
noAction(); noAction();
}); });
gameObject.SetActive(true);
} }
private void Hide() private void Hide()
+23
View File
@@ -0,0 +1,23 @@
using UnityEditor;
using UnityEngine;
public class TestingQuestionDialog : MonoBehaviour
{
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
QuestionDialogUI.Instance.ShowQuestion("To be or not to be ?",
() =>
{
Application.Quit();
EditorApplication.ExitPlaymode();
},
() =>
{
//do nothing
});
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9922754e62fe4b84397a0d1f84482f7e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: