Text field always active

Hi everyone,

I’m trying to make a small 2D game using texts. In it, the player is supposed to type lot of stuff, that’s why I’m looking for a way to set a text field always active, in which the player could type any text whenever he wants, without interacting with any button to activate it (like GUI text. I’m looking for an always active GUI text ^^)

For exemple: the main character moves using arrows keys, and if the player types “hello”, it shows “hello” dynamically in the text field.

The goal would be to make the player type specific words to make events happen. Like “open” in front of a door would open it.

Anyway, I searched a lot and tried many different things but I really don’t know where to start.

Any clue ?

Thanks a lot !

One solutions is to use a GUIText object, not a GUI.TextField() or a GUI.TextArea(). Then you can capture the keystrokes using Input.inputString(). And there is a script on the ‘inputString’ reference page for capturing the keystrokes.

For GUI, you can just set the focus to your TextField or TextArea each frame using GUI.SetFocus(). See the reference page of FocusControl for an example script. Note if the control loses and then regains focus, the text inside will be selected resulting in keystrokes replacing the contents. If that is not what you want, see this answer: