96 lines
2.0 KiB
C#
96 lines
2.0 KiB
C#
// ***********************************************************************
|
|
// Assembly : Game
|
|
// Author : Kimch
|
|
// Created : 2021-01-08
|
|
// Description :
|
|
// Last Modified By :
|
|
// Last Modified On :
|
|
// ***********************************************************************
|
|
// <copyright file= "TextBox.View" company="Kunpo"></copyright>
|
|
// <summary></summary>
|
|
// ***********************************************************************
|
|
namespace G.UI
|
|
{
|
|
using System;
|
|
using TMPro;
|
|
using UnityEngine.UI;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
partial class TextBox
|
|
{
|
|
#region Field
|
|
|
|
#pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
|
|
[KUIFlag]
|
|
TextMeshProUGUI _tmpTitle;
|
|
[KUIFlag]
|
|
TextMeshProUGUI _tmpTitle2;
|
|
[KUIFlag]
|
|
TMP_InputField _inputFiled;
|
|
[KUIFlag]
|
|
Button _btnConfirm;
|
|
[KUIFlag]
|
|
Button _btnClose;
|
|
#pragma warning restore CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
|
|
|
|
#endregion
|
|
|
|
#region Method
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public void InitView()
|
|
{
|
|
SetViewData();
|
|
_btnConfirm.onClick.AddListener(this.OnConfirm);
|
|
_btnClose.onClick.AddListener(this.OnCloseBtnClick);
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public void RefreshView()
|
|
{
|
|
if (this.data is Tuple<string, string, string, Action<string>> tuple)
|
|
{
|
|
_tmpTitle.text = tuple.Item1;
|
|
_tmpTitle2.text = tuple.Item2;
|
|
_inputFiled.text = tuple.Item3;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public void UpdateView()
|
|
{
|
|
}
|
|
|
|
private void OnConfirm()
|
|
{
|
|
SoundProxy.PlayFxAsync(GlobalDefine.BUTTON_CLICK_SOUND);
|
|
var str = _inputFiled.text;
|
|
if (str.Length == 0)
|
|
{
|
|
ToastBox.ShowText("字符数量不符合.");
|
|
return;
|
|
}
|
|
if (this.data is Tuple<string, string, string, Action<string>> tuple)
|
|
{
|
|
tuple.Item4?.Invoke(_inputFiled.text);
|
|
}
|
|
CloseWindow(this);
|
|
}
|
|
|
|
private void OnCloseBtnClick()
|
|
{
|
|
CloseWindow(this);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|