最终效果如:
上代码
using UnityEngine.EventSystems;
///
/// 该脚本挂在InputField上
///
public class Test : MonoBehaviour, IPointerClickHandler
{
private InputField inputField;
private bool isClick;
private void Awake()
{
inputField = GetComponent<InputField>();
inputField.onEndEdit.AddListener(content => isClick = false);
}
private void LateUpdate()
{
if (isClick)
inputField.touchScreenKeyboard.selection = new RangeInt(0, inputField.touchScreenKeyboard.text.Length);
}
public void OnPointerClick(PointerEventData eventData)
{
isClick = true;
}
}
以上代码即可实现该功能,目前能想到的方法就只有这一种,有更好办法的大佬欢迎指正
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)