| | 1 | | using TMPro; |
| | 2 | | using UnityEngine; |
| | 3 | | using UnityEngine.UI; |
| | 4 | |
|
| | 5 | | public class UserContextConfirmationDialog : MonoBehaviour, IConfirmationDialog |
| | 6 | | { |
| | 7 | | public TextMeshProUGUI dialogText; |
| | 8 | | public Button cancelButton; |
| | 9 | | public Button confirmButton; |
| | 10 | |
|
| 1 | 11 | | public void Awake() { } |
| | 12 | |
|
| 14 | 13 | | public void SetText(string text) { dialogText.text = text; } |
| | 14 | |
|
| | 15 | | public void Show(System.Action onConfirm = null, System.Action onCancel = null) |
| | 16 | | { |
| 7 | 17 | | confirmButton.onClick.RemoveAllListeners(); |
| 7 | 18 | | confirmButton.onClick.AddListener(() => |
| | 19 | | { |
| 3 | 20 | | onConfirm?.Invoke(); |
| 3 | 21 | | Hide(); |
| 3 | 22 | | }); |
| | 23 | |
|
| 7 | 24 | | cancelButton.onClick.RemoveAllListeners(); |
| 7 | 25 | | cancelButton.onClick.AddListener(() => |
| | 26 | | { |
| 2 | 27 | | onCancel?.Invoke(); |
| 2 | 28 | | Hide(); |
| 2 | 29 | | }); |
| | 30 | |
|
| 7 | 31 | | gameObject.SetActive(true); |
| 7 | 32 | | } |
| | 33 | |
|
| 66 | 34 | | public void Hide() { gameObject.SetActive(false); } |
| | 35 | | } |