public void Show(Key headerText, Key messageText, Key confirmButtonText, Key declineButtonText, UnityAction confirmCall = null, UnityAction declineCall = null, bool showNameInputIfAvailable = true, Action <string, string> confirmPasswordCallback = null) { _canvas.enabled = true; header.SetText(headerText); message.SetText(messageText); if (nameInput && !showNameInputIfAvailable) { var nameRectPos = nameInput.GetComponent <RectTransform>().anchoredPosition; Destroy(nameInput.gameObject); var passwordRect = passwordInput.GetComponent <RectTransform>(); var middlePoint = Vector2.Lerp(nameRectPos, passwordRect.anchoredPosition, 0.5f); passwordRect.anchoredPosition = middlePoint; } if (passwordInput) { confirm.onClick.AddListener(() => confirmPasswordCallback?.Invoke(nameInput && showNameInputIfAvailable ? nameInput.text : "", passwordInput.text)); passwordShowHide.onClick.AddListener(() => { if (passwordInput.contentType == TMP_InputField.ContentType.Password) { passwordShowHide.GetComponent <Image>().sprite = hide; passwordInput.contentType = TMP_InputField.ContentType.Standard; } else { passwordShowHide.GetComponent <Image>().sprite = show; passwordInput.contentType = TMP_InputField.ContentType.Password; } passwordInput.ActivateInputField(); }); } confirm.GetComponentInChildren <LocalizedText>().SetText(confirmButtonText); decline.GetComponentInChildren <LocalizedText>().SetText(declineButtonText); if (confirmCall != null) { confirm.onClick.AddListener(confirmCall); } if (declineCall != null) { decline.onClick.AddListener(declineCall); } confirm.onClick.AddListener(Close); decline.onClick.AddListener(Close); }
public void Show(Key headerText, Key messageText, Key confirmButtonText, UnityAction confirmCall = null) { _canvas.enabled = true; header.SetText(headerText); message.SetText(messageText); confirm.GetComponentInChildren <LocalizedText>().SetText(confirmButtonText); var rectTransform = confirm.GetComponent <RectTransform>(); rectTransform.anchoredPosition = new Vector2(0, rectTransform.anchoredPosition.y); if (confirmCall != null) { confirm.onClick.AddListener(confirmCall); } confirm.onClick.AddListener(Close); Destroy(decline.gameObject); }