Hi everybody, I’ve been having problems with the TextField function and I’m not really sure how to solve it. I’m creating a typer game prototype, where the player writes types actions in a textField. The idea is for players to type their action and then press ‘Return’ to submit the string to the system. The problem comes from the fact that, if the textField is selected, Input.GetKey() does not register the ‘Return’ key. It is not until the user clicks outside the text field that Input starts registering keys again. I could place a button next to the text field, but I want the game to be keyboard only. Does anyone have any suggestions so I can listen to other keys while the TextField is selected? Any info, or other solution you can think of would really help.
Strangely they removed Input-eatKeyPressOnTextFieldFocus from the Input documentation. However this has been asked several times:
This has worked well for me:
text = GUI.TextField(new Rect(0,0,100,400), text); bool enterClicked = text.Contains("\r") || text.Contains("
nameField = nameField.Trim('\r', '
This example should help: