/// <summary> /// Display a popup message /// </summary> /// <param name="title">Title of the popup</param> /// <param name="message">Message of the popup</param> /// <param name="buttons">Buttons of the popup</param> /// <param name="buttonClickedCallback">Callback to call when a button has been clicked</param> /// <param name="data">Data to send to the popup</param> public void Popup(string title, string message, string[] buttons, PopupButtonClicked buttonClickedCallback = null, object data = null) { CurrentScreenGameObject.GetComponent <CanvasGroup>().blocksRaycasts = false; _popupGameObject.transform.SetAsLastSibling(); UnityPopupScreen.Instance.Title = title; UnityPopupScreen.Instance.Message = message; UnityPopupScreen.Instance.Buttons = buttons; UnityPopupScreen.Instance.Show(button => { CurrentScreenGameObject.GetComponent <CanvasGroup>().blocksRaycasts = true; buttonClickedCallback?.Invoke(button); }); }
public void Hide() { _buttonClickedCallback = null; StartCoroutine(_Hide()); }
public virtual void Show(PopupButtonClicked buttonClickedCallback = null, object data = null) { _buttonClickedCallback = buttonClickedCallback; gameObject.SetActive(true); StartCoroutine(transform.GetChild(0).Scale(Vector3.zero, Vector3.one, 0.25f)); }
protected virtual void OnPopupButtonClicked(EventArgs e) { PopupButtonClicked?.Invoke(this, e); }
/// <summary> /// Display a popup message /// </summary> /// <param name="title">Title of the popup</param> /// <param name="message">Message of the popup</param> /// <param name="button">Button of the popup</param> /// <param name="buttonClickedCallback">Callback to call when a button has been clicked</param> /// <param name="data">Data to send to the popup</param> public void Popup(string title, string message, string button, PopupButtonClicked buttonClickedCallback = null, object data = null) { Popup(title, message, new [] { button }, buttonClickedCallback, data); }
/// <summary> /// Display a popup message with OK and Cancel buttons /// </summary> /// <param name="title">Title of the popup</param> /// <param name="message">Message of the popup</param> /// <param name="buttonClickedCallback">Callbakc to call when a button has been clicked</param> /// <param name="data">Data to send to the popup</param> public void PopupOkCancel(string title, string message, PopupButtonClicked buttonClickedCallback = null, object data = null) { Popup(title, message, new[] { "Ok", "Cancel" }, buttonClickedCallback); }