Hi.
I am looking for a solution on how to give focus to an InputField in the new UI system. I came across this:
void Update()
{
if (Input.GetKeyDown(KeyCode.A))
{
EventSystem.current.SetSelectedGameObject(input.gameObject, null);
input.OnPointerClick(null);
}
}
The problem is that I get a NullReferenceException on line 6. Others have succesfully used this solution so I would appreciate any help as to why this is not working for me.
Kesh found a solution which he posted in the Developer Preview forum:
EventSystem.current.SetSelectedGameObject(inputField.gameObject, null);
inputField.OnPointerClick(new PointerEventData(EventSystem.current));
http://forum.unity3d.com/threads/focus-on-inputfield-programmatically.264472/#post-1801779