Esempio n. 1
0
        /// <summary>
        /// Creates a prompt dialog that can be modified or stored before showing.
        /// <para></para>
        /// Before calling <see cref="DialogPrompt.Show"/>, call <see cref="DialogPrompt.Initialize(string,string,Action{string, string},string,string,ImageData,Action,string)"/>.
        /// <para></para>
        /// For a simpler solution with less customizability, use <see cref="ShowPrompt(string,string,Action{string, string},string,string,ImageData,Action,string)"/>.
        /// </summary>
        /// <returns>The instance of the created dialog.</returns>
        public static DialogPrompt CreatePrompt()
        {
            DialogPrompt dialog = PrefabManager.InstantiateGameObject(PrefabManager.ResourcePrefabs.dialogPrompt, instance.transform).GetComponent <DialogPrompt>();

            dialog.Initialize();
            return(dialog);
        }
Esempio n. 2
0
        protected virtual void OpenDefaultPromptDialog()
        {
            if (!IsActive() || !IsInteractable())
            {
                return;
            }

            DialogManager.ShowPromptAsync(this,
                                          (value) =>
            {
                if (this != null)
                {
                    this.text = value;
                    if (OnReturnPressed != null)
                    {
                        OnReturnPressed.Invoke();
                    }
                }
            },
                                          "OK",
                                          this.hintText,
                                          null,
                                          null,
                                          "Cancel",
                                          (dialog) =>
            {
                _dialogPrompt = dialog;
                if (_dialogPrompt != null)
                {
                    _dialogPrompt.destroyOnHide = true;
                }
            });
        }
Esempio n. 3
0
        /// <summary>
        /// Shows a prompt dialog with an optional title, optional icon, a required input field, an optional input field, a required button, and an optional button.
        /// <para></para>
        /// For more customizability, use <see cref="CreatePrompt"/>.
        /// </summary>
        /// <param name="firstFieldName">Name of the first field.</param>
        /// <param name="secondFieldName">Name of the second field. Make null for no second field.</param>
        /// <param name="onAffirmativeButtonClicked">Called when the affirmative button is clicked.</param>
        /// <param name="affirmativeButtonText">The affirmative button text.</param>
        /// <param name="titleText">The title text. Make null for no title.</param>
        /// <param name="icon">The icon next to the title. Make null for no icon.</param>
        /// <param name="onDismissiveButtonClicked">Called when the dismissive button is clicked.</param>
        /// <param name="dismissiveButtonText">The dismissive button text. Make null for no dismissive button.</param>
        /// <returns>The instance of the initialized, shown dialog.</returns>
        public static DialogPrompt ShowPrompt(string firstFieldName, string secondFieldName, Action <string, string> onAffirmativeButtonClicked, string affirmativeButtonText, string titleText, ImageData icon, Action onDismissiveButtonClicked, string dismissiveButtonText)
        {
            DialogPrompt dialog = CreatePrompt();

            dialog.Initialize(firstFieldName, secondFieldName, onAffirmativeButtonClicked, affirmativeButtonText, titleText, icon, onDismissiveButtonClicked, dismissiveButtonText);
            dialog.Show();
            return(dialog);
        }
Esempio n. 4
0
        /// <summary>
        /// Creates a prompt dialog that can be modified or stored before showing.
        /// <para></para>
        /// Before calling <see cref="DialogPrompt.Show"/>, call <see cref="DialogPrompt.Initialize(string,string,Action{string, string},string,string,ImageData,Action,string)"/>.
        /// <para></para>
        /// For a simpler solution with less customizability, use <see cref="ShowPrompt(string,string,Action{string, string},string,string,ImageData,Action,string)"/>.
        /// </summary>
        /// <returns>The instance of the created dialog.</returns>
        public DialogPrompt CreatePrompt()
        {
            DialogPrompt dialog = PrefabManager.InstantiateGameObject(PrefabManager.ResourcePrefabs.dialogPrompt, GetContentTransform()).GetComponent <DialogPrompt>();

            DialogManager.CreateActivity(dialog, dialog.transform.parent);
            //dialog.Initialize();
            return(dialog);
        }
Esempio n. 5
0
        protected virtual void OpenPromptDialog()
        {
            if (!IsActive() || !IsInteractable())
            {
                return;
            }

            if (string.IsNullOrEmpty(m_CustomDialogPath))
            {
                OpenDefaultPromptDialog();
            }
            else
            {
                DialogManager.ShowCustomDialogAsync <DialogPrompt>(m_CustomDialogPath, (dialog) =>
                {
                    _dialogPrompt = dialog;
                    if (_dialogPrompt != null)
                    {
                        _dialogPrompt.destroyOnHide = true;
                        _dialogPrompt.Initialize(this,
                                                 (value) =>
                        {
                            if (this != null)
                            {
                                value          = string.IsNullOrEmpty(value) ? string.Empty : value;
                                var willChange = m_Text != value;

                                this.text = value;
                                if (willChange && onEndEdit != null)
                                {
                                    onEndEdit.Invoke(m_Text);
                                }
                                if (OnReturnPressed != null)
                                {
                                    OnReturnPressed.Invoke();
                                }
                            }
                        },
                                                 "OK",
                                                 this.hintText,
                                                 null,
                                                 null,
                                                 "Cancel");
                    }
                    else
                    {
                        OpenDefaultPromptDialog();
                    }
                });
            }
        }