来自于:万士辰

    1. void Update()
    2. {
    3. //识别键盘输入
    4. //键盘A键按住
    5. //第一种方式 "a" 必须是小写字母
    6. if (Input.GetKey("a"))
    7. {
    8. }
    9. //第二种方式 KeyCode的枚举类型
    10. if (Input.GetKey(KeyCode.A))
    11. {
    12. }
    13. //键盘A按下瞬间
    14. if (Input.GetKeyDown("a"))
    15. {
    16. }
    17. if (Input.GetKeyDown(KeyCode.A))
    18. {
    19. }
    20. //键盘A抬起瞬间
    21. if (Input.GetKeyUp("a"))
    22. {
    23. }
    24. if (Input.GetKeyUp(KeyCode.A))
    25. {
    26. }
    27. //识别鼠标输入
    28. //鼠标左键按住
    29. //int 0 (右键1 中键2)
    30. if (Input.GetMouseButton(0))
    31. {
    32. }
    33. //鼠标左键按下瞬间
    34. if (Input.GetMouseButtonDown(0))
    35. {
    36. }
    37. //鼠标左键抬起瞬间
    38. if (Input.GetMouseButtonUp(0))
    39. {
    40. }
    41. }