如何调用方法 onEndEdit inputfield 或 Ok 按钮统一点击?
How can call method onEndEdit inputfield or Ok button clicked in unity?
我的应用程序中有一个用于搜索词的输入字段 统一开发。
在 android 移动设备上,我需要找到用户点击“确定”或“完成”或编辑输入字段端以调用方法进行搜索的时间。
好的,在尝试了很多代码和文档之后!解决了:
public void Start()
{
//Adds a listener that invokes the "LockInput" method when the player finishes editing the main input field.
//Passes the main input field into the method when "LockInput" is invoked
termInputField.onEndEdit.AddListener(delegate { LockInput(termInputField); });
}
void LockInput(TMP_InputField input)
{
if (input.text.Length > 2)
{
Debug.Log("Text has been entered");
DoSearch();
}
else if (input.text.Length == 0)
{
Debug.Log("Main Input Empty");
}
}
public void DoSearch()
{
//My Code For Doing Search!
}
我的应用程序中有一个用于搜索词的输入字段 统一开发。
在 android 移动设备上,我需要找到用户点击“确定”或“完成”或编辑输入字段端以调用方法进行搜索的时间。
好的,在尝试了很多代码和文档之后!解决了:
public void Start()
{
//Adds a listener that invokes the "LockInput" method when the player finishes editing the main input field.
//Passes the main input field into the method when "LockInput" is invoked
termInputField.onEndEdit.AddListener(delegate { LockInput(termInputField); });
}
void LockInput(TMP_InputField input)
{
if (input.text.Length > 2)
{
Debug.Log("Text has been entered");
DoSearch();
}
else if (input.text.Length == 0)
{
Debug.Log("Main Input Empty");
}
}
public void DoSearch()
{
//My Code For Doing Search!
}