Added basic popup action menu
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ItemActionsUI : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private TextMeshProUGUI _title;
|
||||
[SerializeField]
|
||||
private TextMeshProUGUI _description;
|
||||
|
||||
[SerializeField]
|
||||
private Button _btnCancel;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
|
||||
public void Show(string title, string description)
|
||||
{
|
||||
_title.text = title;
|
||||
_description.text = description;
|
||||
|
||||
_btnCancel.onClick.AddListener(() =>
|
||||
{
|
||||
Hide();
|
||||
});
|
||||
gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
private void Hide()
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
//Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public class TestingQuestionDialog : MonoBehaviour
|
||||
{
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Escape))
|
||||
{
|
||||
YesNoDialogUI.Instance.ShowQuestion("To be or not to be ?",
|
||||
() =>
|
||||
{
|
||||
Application.Quit();
|
||||
EditorApplication.ExitPlaymode();
|
||||
},
|
||||
() =>
|
||||
{
|
||||
//do nothing
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9922754e62fe4b84397a0d1f84482f7e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,44 +0,0 @@
|
||||
|
||||
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