I’d like to check the input field WHILE typing. I can check the result when it’s been changed (i.e., when you leave the field), but I want to check it LIVE, while typing. I have not been able to find anything online to give me a clue as to how to do this. Can anyone help?
Hello,
Yes, this is easy to do through code. You just need to use the UnityEngine.UI namespace, get the Input Field component you want to access, and then use InputField.text to get the Input Field text. You can get it every frame to have it update live.
Example:
using UnityEngine;
using UnityEngine.UI;
public class GetInputText : MonoBehaviour
{
InputField inputField;
void Start()
{
inputField = GetComponent<InputField>();
}
void Update()
{
Debug.Log(inputField.text);
}
}
What Unrighteous says above, OR you can also hook this:
and at the same time see what is in the field, but only when new characters come in.
Thanks for your help. I liked Unrighteous’ solution better.
1 Like