|
| 1 | +using UnityEngine; |
| 2 | +using System.Collections; |
| 3 | +using NativeDialog; |
| 4 | + |
| 5 | +public class NativeDialogSample : MonoBehaviour |
| 6 | +{ |
| 7 | + [SerializeField] private string decideLabel = "Decide"; |
| 8 | + [SerializeField] private string cancelLabel = "Cancel"; |
| 9 | + [SerializeField] private string closeLabel = "Close"; |
| 10 | + |
| 11 | + private void Start() |
| 12 | + { |
| 13 | + DialogManager.Instance.SetLabel(decideLabel, cancelLabel, closeLabel); |
| 14 | + } |
| 15 | + |
| 16 | + #region Invoked from Unity GUI |
| 17 | + |
| 18 | + public void ShowSelectDialog() |
| 19 | + { |
| 20 | + const string message = "A simple select dialog"; |
| 21 | + DialogManager.Instance.ShowSelectDialog(message, (bool result) => |
| 22 | + { |
| 23 | + Debug.Log($"{result}: {message}"); |
| 24 | + }); |
| 25 | + } |
| 26 | + |
| 27 | + public void ShowSelectDialogWithTitle() |
| 28 | + { |
| 29 | + const string title = "A title"; |
| 30 | + const string message = "A message for select dialog"; |
| 31 | + DialogManager.Instance.ShowSelectDialog(title, message, (bool result) => |
| 32 | + { |
| 33 | + Debug.Log($"{result}: {title} / {message}"); |
| 34 | + }); |
| 35 | + } |
| 36 | + |
| 37 | + public void ShowSubmitDialog() |
| 38 | + { |
| 39 | + const string message = "A simple submit dialog"; |
| 40 | + DialogManager.Instance.ShowSubmitDialog(message, (bool result) => |
| 41 | + { |
| 42 | + Debug.Log($"{result}: {message}"); |
| 43 | + }); |
| 44 | + } |
| 45 | + |
| 46 | + public void ShowSubmitDialogWithTitle() |
| 47 | + { |
| 48 | + const string title = "A title"; |
| 49 | + const string message = "A message for submit dialog"; |
| 50 | + DialogManager.Instance.ShowSubmitDialog(title, message, (bool result) => |
| 51 | + { |
| 52 | + Debug.Log($"{result}: {title} / {message}"); |
| 53 | + }); |
| 54 | + } |
| 55 | + |
| 56 | + public void ShowDialogWithAutoDissmiss() |
| 57 | + { |
| 58 | + const string message = "A dialog with auto dismiss"; |
| 59 | + int id = DialogManager.Instance.ShowSelectDialog(message, (bool result) => |
| 60 | + { |
| 61 | + Debug.Log($"{result}: {message}"); |
| 62 | + }); |
| 63 | + StartCoroutine(Dissmiss(id, 3f)); |
| 64 | + } |
| 65 | + |
| 66 | + #endregion // Invoked from Unity GUI |
| 67 | + |
| 68 | + private IEnumerator Dissmiss(int id, float time) |
| 69 | + { |
| 70 | + yield return new WaitForSeconds(time); |
| 71 | + DialogManager.Instance.DissmissDialog(id); |
| 72 | + } |
| 73 | +} |
0 commit comments