31 lines
699 B
C#
31 lines
699 B
C#
using System;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
namespace HK.FUJIFILM
|
|
{
|
|
public class InputLimitLength : MonoBehaviour
|
|
{
|
|
private TMP_InputField inputField;
|
|
public int count;
|
|
|
|
private void Awake()
|
|
{
|
|
inputField = GetComponent<TMP_InputField>();
|
|
inputField.onValueChanged.AddListener(OnValueChanged);
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
inputField.onValueChanged.RemoveListener(OnValueChanged);
|
|
}
|
|
|
|
private void OnValueChanged(string arg0)
|
|
{
|
|
if (arg0.Length > count)
|
|
{
|
|
inputField.text = arg0.Substring(0, count);
|
|
}
|
|
}
|
|
}
|
|
} |