UI_Keyboard.cs 726 B

12345678910111213141516171819202122232425262728293031323334
  1. namespace VRTK.Examples
  2. {
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class UI_Keyboard : MonoBehaviour
  6. {
  7. private InputField input;
  8. public void ClickKey(string character)
  9. {
  10. input.text += character;
  11. }
  12. public void Backspace()
  13. {
  14. if (input.text.Length > 0)
  15. {
  16. input.text = input.text.Substring(0, input.text.Length - 1);
  17. }
  18. }
  19. public void Enter()
  20. {
  21. VRTK_Logger.Info("You've typed [" + input.text + "]");
  22. input.text = "";
  23. }
  24. private void Start()
  25. {
  26. input = GetComponentInChildren<InputField>();
  27. }
  28. }
  29. }