2
\$\begingroup\$

I have been stuck on this problem for a long time and not sure what I need to do. Would appreciate any help.

I am building an Android app using Unity. In my app I have an InputField, a TMP_InputField to be precise, in my Unity scene as a Prefab. I want to edit this input field by clicking on a button in my Android UI (not part of Unity scene). I don't want the input field to be editable by clicking on the input field itself.

In order to achieve this, I enabled the Hide Soft keyboard option in the editor so that user can't edit the field by clicking on the field. But I am not able to figure out how to edit the input field.

First problem is how to pop up the keyboard when I click on the Android button. I tried this.

TouchScreenKeyboard.Open("");

This pops up the keyboard but the input field doesn't show the caret and doesn't accept input.

I also tried,

EventSystem.current.SetSelectedGameObject(inputField.gameObject, null);
inputField.OnPointerClick(null);

and

inputField.Select();
inputField.ActivateInputField();

But no success. I tried to play with the focused, interactable, activated properties but nothing works.

This should be easy but I am unable to get it to work. Would really appreciate any help. Thanks!

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.