Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6.  
  7. public class NewBehaviourScript : MonoBehaviour {
  8.  
  9. public Text textTesterLinux;
  10.  
  11. void KK()
  12. {
  13. if (textTesterLinux == null) { return; }
  14.  
  15. var pressedKeyCode = KeyCode.None;
  16. if (Input.anyKeyDown)
  17. {
  18.  
  19. pressedKeyCode = FetchKey();
  20.  
  21. if (pressedKeyCode != KeyCode.None)
  22. {
  23. textTesterLinux.text = "keycode " + "{" + pressedKeyCode + "}" + " keycodeCODE " + "{" + (int)pressedKeyCode + "}";
  24. }
  25. }
  26. else
  27. if (Input.anyKey)
  28. {
  29. pressedKeyCode = FetchKey();
  30. if (pressedKeyCode != KeyCode.None)
  31. {
  32. textTesterLinux.text = "999 keycode " + "{" + pressedKeyCode + "}" + " keycodeCODE " + "{" + (int)pressedKeyCode + "}";
  33. }
  34.  
  35.  
  36. }
  37. }
  38.  
  39.  
  40. KeyCode FetchKey()
  41. {
  42. foreach (KeyCode kk in Enum.GetValues(typeof(KeyCode)))
  43. {
  44. if (Input.GetKeyDown(kk))
  45. {
  46. return kk;
  47. }
  48. }
  49.  
  50. return KeyCode.None;
  51. }
  52.  
  53. // Use this for initialization
  54. void Start () {
  55.  
  56. }
  57.  
  58. // Update is called once per frame
  59. void Update () {
  60. KK();
  61.  
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement