public void PromptText(string title, string message, string acceptButtonText, string cancelButtonText, Action <string> onEntered, Action onCancelled) { ClearAll(); if (textPromptTitle != null) { textPromptTitle.text = title; } textPromptText.text = message; textPromptInput.text = ""; textPromptButtonAccept.gameObject.SetActive(true); textPromptButtonCancel.gameObject.SetActive(true); var btnText = textPromptButtonAccept.GetComponentInChildren <Text>(); if (btnText != null) { btnText.text = acceptButtonText; } btnText = textPromptButtonCancel.GetComponentInChildren <Text>(); if (btnText != null) { btnText.text = cancelButtonText; } textPromptButtonAccept.onClick.RemoveAllListeners(); textPromptButtonAccept.onClick.AddListener(() => { background.SetActive(false); StartCoroutine(UIAnimator.AnimationRoutine(textPromptContainer, -1, () => { textPromptContainer.gameObject.SetActive(false); ModalClosed(); if (onEntered != null) { onEntered(textPromptInput.text); } })); }); textPromptButtonCancel.onClick.RemoveAllListeners(); textPromptButtonCancel.onClick.AddListener(() => { background.SetActive(false); StartCoroutine(UIAnimator.AnimationRoutine(textPromptContainer, -1, () => { textPromptContainer.gameObject.SetActive(false); ModalClosed(); if (onCancelled != null) { onCancelled(); } })); }); background.SetActive(true); textPromptContainer.gameObject.SetActive(true); StartCoroutine(UIAnimator.AnimationRoutine(textPromptContainer, 1)); }
// Yes/no promt public void PromptYesNo(string title, string message, string yesButtonText, string noButtonText, Action onYes, Action onNo) { ClearAll(); if (promptTitle != null) { promptTitle.text = title; } promptText.text = message; var btnText = promptButtonYes.GetComponentInChildren <Text>(); if (btnText != null) { btnText.text = yesButtonText; } btnText = promptButtonNo.GetComponentInChildren <Text>(); if (btnText != null) { btnText.text = noButtonText; } promptButtonYes.onClick.RemoveAllListeners(); promptButtonYes.onClick.AddListener(() => { background.SetActive(false); StartCoroutine(UIAnimator.AnimationRoutine(promptContainer, -1, () => { promptContainer.gameObject.SetActive(false); ModalClosed(); if (onYes != null) { onYes(); } })); }); promptButtonNo.onClick.RemoveAllListeners(); promptButtonNo.onClick.AddListener(() => { background.SetActive(false); StartCoroutine(UIAnimator.AnimationRoutine(promptContainer, -1, () => { promptContainer.gameObject.SetActive(false); ModalClosed(); if (onNo != null) { onNo(); } })); }); background.SetActive(true); promptContainer.gameObject.SetActive(true); StartCoroutine(UIAnimator.AnimationRoutine(promptContainer, 1)); }
// Generic error public void ShowError(string title, string message, string buttonText, Action onDismissed) { ClearAll(); if (errorBoxTitle != null) { errorBoxTitle.text = title; } errorBoxText.text = message; var btnText = errorBoxButton.GetComponentInChildren <Text>(); if (btnText != null) { btnText.text = buttonText; } errorBoxButton.onClick.RemoveAllListeners(); errorBoxButton.onClick.AddListener(() => { background.SetActive(false); StartCoroutine(UIAnimator.AnimationRoutine(errorBoxContainer, -1, () => { errorBoxContainer.gameObject.SetActive(false); ModalClosed(); if (onDismissed != null) { onDismissed(); } })); }); background.SetActive(true); errorBoxContainer.gameObject.SetActive(true); StartCoroutine(UIAnimator.AnimationRoutine(errorBoxContainer, 1)); }
public void Hide() { StartCoroutine(UIAnimator.AnimationRoutine(this, -1f, () => { gameObject.SetActive(false); })); }
public void Show() { gameObject.SetActive(true); StartCoroutine(UIAnimator.AnimationRoutine(this, 1f)); }