Advertisement
ilih

Untitled

Mar 23rd, 2022
1,086
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     using UIWidgets;
  2.     using UnityEngine;
  3.     using UnityEngine.Events;
  4.     using UnityEngine.EventSystems;
  5.  
  6.     [RequireComponent(typeof(InputFieldAdapter))]
  7.     public class OculusKeyboardAdapter : MonoBehaviour, ISelectHandler, IUpdatable
  8.     {
  9.         TouchScreenKeyboard overlayKeyboard;
  10.  
  11.         InputFieldAdapter input;
  12.  
  13.         void Start()
  14.         {
  15.             input = GetComponent<InputFieldAdapter>();
  16.         }
  17.  
  18.         public void OnSelect(BaseEventData eventData)
  19.         {
  20.             overlayKeyboard = TouchScreenKeyboard.Open(input.Value, TouchScreenKeyboardType.Default);
  21.             Updater.Add(this);
  22.         }
  23.  
  24.         public void RunUpdate()
  25.         {
  26.             if (!overlayKeyboard.active)
  27.             {
  28.                 input.Value = overlayKeyboard.text;
  29.                 Updater.Remove(this);
  30.                 overlayKeyboard = null;
  31.  
  32.                 return;
  33.             }
  34.  
  35.             input.Value = overlayKeyboard.text;
  36.         }
  37.     }
Advertisement
RAW Paste Data Copied
Advertisement