Reselecting InputField

I’m making a simple hangman game in 4.6 and I’ve got pretty much everything done, but the player has to click the InputField in order to type in it, and when they submit, the InputField is deselected. I tried to select the field again using SetSelectedGameObject
EventSystemManager.currentSystem.SetSelectedGameObject (inputField,null);
but I get the error
Argument #1' cannot convert UnityEngine.UI.InputField’ expression to type `UnityEngine.GameObject’
I’m assuming this is because most of the new UI elements aren’t counted as GameObjects yet.
Is there a way to make sure the InputField is always selected so the player can type in it, or at least doesn’t deselect when the player submits?

PS, this is the code I’m using for submiting

inputField.onSubmit.AddListener((value) => SubmitGuess(value)); submitButton.onClick.AddListener(() => SubmitGuess(inputField.value));

It deselects the InputField in both types of submission.

In b20 and b21 I use:

inputField.Select();
inputField.ActivateInputField();
1 Like

I agree with what Wenzil says but to add to your knowledge here is more info.

No UI elements will never be counted as GameObjects UI elements are components just like “Light” or “Animation” or “Camera”. All components are attached to a GameObject so you can do myComponent.gameObject to get the GameObject for that component.