You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

51 lines
1.1 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using System.Runtime.InteropServices;
using System;
public class WebGLKeyboard : MonoBehaviour, ISelectHandler
{
[DllImport("__Internal")]
private static extern void focusHandleAction(string _name, string _str);
private InputField UnityInput;
private TMPro.TMP_InputField TMPInput;
private void Awake()
{
UnityInput = GetComponent<InputField>();
TMPInput = GetComponent<TMPro.TMP_InputField>();
}
public void ReceiveInputData(string value)
{
if (TMPInput != null)
TMPInput.text = value;
else if (UnityInput != null)
UnityInput.text = value;
}
public void OnSelect(BaseEventData data)
{
#if UNITY_WEBGL
try
{
if (TMPInput != null)
focusHandleAction(gameObject.name, TMPInput.text);
else if (UnityInput != null)
focusHandleAction(gameObject.name, UnityInput.text);
}
catch (Exception error) { }
#endif
}
}