Beispiel #1
0
 protected override void OnDeactivate()
 {
     if (dialog != null)
     {
         // Klei destroys the dialog GameObject for us
         dialog.DialogClosed?.Invoke(key);
     }
     base.OnDeactivate();
     dialog = null;
 }
Beispiel #2
0
        /// <summary>
        /// Shows a confirmation dialog.
        /// </summary>
        /// <param name="parent">The dialog's parent.</param>
        /// <param name="message">The message to display.</param>
        /// <param name="onConfirm">The action to invoke if Yes or OK is selected.</param>
        /// <param name="onCancel">The action to invoke if No or Cancel is selected.</param>
        /// <param name="confirmText">The text for the OK/Yes button.</param>
        /// <param name="cancelText">The text for the Cancel/No button.</param>
        /// <returns>The dialog created.</returns>
        public static ConfirmDialogScreen ShowConfirmDialog(GameObject parent, string message,
                                                            System.Action onConfirm, System.Action onCancel = null,
                                                            string confirmText = null, string cancelText = null)
        {
            if (parent == null)
            {
                parent = PDialog.GetParentObject();
            }
            var obj = Util.KInstantiateUI(ScreenPrefabs.Instance.ConfirmDialogScreen.
                                          gameObject, parent, false);
            var confirmDialog = obj.GetComponent <ConfirmDialogScreen>();

            UIDetours.POPUP_CONFIRM.Invoke(confirmDialog, message, onConfirm, onCancel ??
                                           DoNothing, null, null, null, confirmText, cancelText);
            obj.SetActive(true);
            return(confirmDialog);
        }