1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. public class ShuRu : MonoBehaviour
    5. {
    6. private void Update()
    7. {
    8. //按下E键
    9. if (Input.GetKeyDown(KeyCode.E))
    10. {
    11. Debug.Log("按下E");
    12. }
    13. //按住M键会一直执行
    14. if (Input.GetKey (KeyCode.M ))
    15. {
    16. Debug.Log("按住M");
    17. }
    18. //N键弹起
    19. if (Input.GetKeyUp (KeyCode.N))
    20. {
    21. Debug.Log("N键弹起");
    22. }
    23. //Input .GetAxis
    24. //Input.GetAxis("Horizontal")和Input.GetAxis("Verical")输出的是float值;
    25. //按下input设置好的虚拟按键
    26. if (Input.GetButtonDown("Fire1"))
    27. {
    28. Debug.Log("按下虚拟按键Fire1");
    29. }
    30. //鼠标左、中、右;0、1、2;
    31. if (Input.GetMouseButtonDown (0)) //一个按键执行多个命令不冲突
    32. {
    33. Debug.Log("按下虚拟按键鼠标左键");
    34. }
    35. }
    36. }