finish yes/no dialog with test
This commit is contained in:
@@ -6,7 +6,7 @@ using UnityEngine.UI;
|
||||
|
||||
public class QuestionDialogUI : MonoBehaviour
|
||||
{
|
||||
//public static QuestionDialogUI Instance { get; private set; }
|
||||
public static QuestionDialogUI Instance { get; private set; }
|
||||
|
||||
[SerializeField]
|
||||
private TextMeshProUGUI _textMeshPro;
|
||||
@@ -16,14 +16,8 @@ public class QuestionDialogUI : MonoBehaviour
|
||||
private Button _noBtn;
|
||||
private void Awake()
|
||||
{
|
||||
// Instance = this;
|
||||
ShowQuestion("Are you sure ?", () =>
|
||||
{
|
||||
Debug.Log("Yes");
|
||||
}, () =>
|
||||
{
|
||||
Debug.Log("No");
|
||||
});
|
||||
Instance = this;
|
||||
Hide();
|
||||
}
|
||||
|
||||
public void ShowQuestion(string questionText, Action yesAction, Action noAction)
|
||||
@@ -39,6 +33,7 @@ public class QuestionDialogUI : MonoBehaviour
|
||||
Hide();
|
||||
noAction();
|
||||
});
|
||||
gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
private void Hide()
|
||||
|
||||
@@ -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:
|
||||
Reference in New Issue
Block a user