// *********************************************************************** // Assembly : Game // Author : Kimch // Created : 2021-01-08 // Description : // Last Modified By : // Last Modified On : // *********************************************************************** // // // *********************************************************************** namespace G.UI { using TMPro; using UnityEngine; using UnityEngine.UI; /// /// /// partial class RedeemBox { #region Field #pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null [KUIFlag] TextMeshProUGUI _tmpTitle; [KUIFlag] TextMeshProUGUI _tmpTitle2; [KUIFlag] TMP_InputField _inputFiled; [KUIFlag] Button _btnConfirm; [KUIFlag] Button _btnClose; [KUIFlag] Button _btnCopy; [KUIFlag] Button _btnPaste; #pragma warning restore CS0649 // 从未对字段赋值,字段将一直保持其默认值 null #endregion #region Method /// /// /// public void InitView() { SetViewData(); _btnCopy.gameObject.SetActive(!string.IsNullOrEmpty(KRemoteConfig.Instance.gongzhonghao)); _btnConfirm.onClick.AddListener(this.OnConfirm); _btnCopy.onClick.AddListener(this.OnCopyBtnClick); _btnClose.onClick.AddListener(this.OnCloseBtnClick); _btnPaste.onClick.AddListener(this.OnPasteBtnClick); } /// /// /// public void RefreshView() { var text = GlobalUtils.GetClipboard(); if (!string.IsNullOrEmpty(text) && text.Length < 16) { _inputFiled.text = text.Trim(); } else { _inputFiled.text = string.Empty; } } private void OnConfirm() { var code = _inputFiled.text; if (string.IsNullOrEmpty(code)) { ToastBox.ShowText("字符数量不符合"); return; } var realCode = ConvertCode(code); ServerProxy.Instance.RedeemCode(realCode); CloseWindow(this); OpenWindow(); SoundProxy.PlayFxAsync(GlobalDefine.BUTTON_CLICK_SOUND); } private void OnCopyBtnClick() { var gongzhonghao = KRemoteConfig.Instance.gongzhonghao; if (string.IsNullOrEmpty(gongzhonghao)) gongzhonghao = "大侠不哭"; KPlatform.Instance.SetClipboardData(gongzhonghao); ToastBox.ShowText("复制成功"); } private void OnPasteBtnClick() { KPlatform.Instance.GetClipboardData((error, message, data) => { if (error == 0) { _inputFiled.text = data as string; ToastBox.ShowText("粘贴成功"); } }); } private void OnCloseBtnClick() { CloseWindow(this); } #endregion } }