I’ve created this script trying to wrap the TMP_InputField to work for any XR device:
using TMPro;
using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit.Samples.SpatialKeyboard;
namespace RitsuKita.UI.Keyboard
{
[RequireComponent(typeof(TMP_InputField))]
public class TextMeshProInputFieldXRKeyboard : MonoBehaviour
{
private TMP_InputField _inputField;
private void Awake()
{
_inputField = GetComponent<TMP_InputField>();
_inputField.shouldHideSoftKeyboard = true; // Turn off to not use a prebuilt keyboard, avoid exceptions to be thrown in case of missing permissions.
}
private void OnEnable()
{
_inputField.onSelect.AddListener(OnSelect);
}
private void OnDisable()
{
_inputField.onSelect.RemoveListener(OnSelect);
}
private void OnSelect(string arg0)
{
GlobalNonNativeKeyboard.instance.ShowKeyboard(_inputField, true);
}
}
}
However, when selecting the text in the game, the keyboard opens, but the text doesnt change or update on pressing submit.
Note worthy is that if I add a XRKeyboard using the prefab and drag and drops a TMP_InputField to the XRKeyboardDisplay.InputField, the text updates.
Same behavior happens in the editor using the XR Device Simulator, as well as deployed to a Meta Quest 3.
No errors or warnings, either in the editor or deployed.
Unity 6000.0.23f1
XR Interaction Toolkit 3.0.6
Input System 1.11.2
Mathematics 1.3.2
XR Core Utilities 2.3.0