#InputField auto reselect after submitting
1 messages · Page 1 of 1 (latest)
public class KeyboardInputController : MonoBehaviour
{
// 35
public InputField inputField;
public Controller controller;
public TextMeshPro console;
private void Update()
{
if (controller.consoleMode)
{
inputField.Select();
inputField.enabled = true;
inputField.readOnly = false;
inputField.interactable = true;
if (Input.GetKeyDown(KeyCode.Return))
{
console.text += inputField.text;
inputField.text = "";
}
}
}
}
as you can see I already tried to set some booleans and calling the select method but nothing worked...
Id not use inputfield for that because you don't really need it and it would be hard to change its core features when you want to make it work differently. You can just use Input.inputString to make your own input field type of system
Okay but does that also handle backspace, caps, shift and so on... ?
Im pretty sure it does handle shift automatically. '\b' is the character that indicates backspace. Input.inputString documentation even have example code to implement backspace https://docs.unity3d.com/ScriptReference/Input-inputString.html
thx
thanks
its finally working