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
|
|
}
|
|
}
|