FM/Assets/Scripts/Base/Keyboard/TMP_InputField_Register.cs

37 lines
1.1 KiB
C#

using System;
using TMPro;
using UnityEngine;
using ZGame;
namespace HK.Keyboard
{
[RequireComponent(typeof(TMP_InputField))]
public class TMP_InputField_Register : MonoBehaviour
{
TMP_InputField inputField;
public Action OKAction;
private void Awake()
{
inputField = GetComponent<TMP_InputField>();
inputField.shouldHideSoftKeyboard = true;
inputField.onSelect.AddListener(SelectInputField);
}
private void OnDestroy()
{
inputField.onSelect.RemoveListener(SelectInputField);
}
private void SelectInputField(string arg0)
{
if (inputField.contentType == TMP_InputField.ContentType.IntegerNumber)
EventManager.Instance.FireNow(OpenKeyboardEventArgs.EventId,
new OpenKeyboardEventArgs(inputField, false, false, KeyboardType.NumberOnly, OKAction));
else
EventManager.Instance.FireNow(OpenKeyboardEventArgs.EventId,
new OpenKeyboardEventArgs(inputField, false, false, OKAction));
}
}
}