必须在Update()方法中调用

 void Update()
    {
        //识别键盘输入
        //键盘A键按住
        //第一种方式 "a" 必须是小写字母
        if (Input.GetKey("a"))
        {
        }
        //第二种方式 KeyCode的枚举类型
        if (Input.GetKey(KeyCode.A))
        {
        }

        //键盘A按下瞬间
        if (Input.GetKeyDown("a"))
        {
        }
        if (Input.GetKeyDown(KeyCode.A))
        {
        }

        //键盘A抬起瞬间
        if (Input.GetKeyUp("a"))
        {
        }
        if (Input.GetKeyUp(KeyCode.A))
        {
        }


        //识别鼠标输入
        //鼠标左键按住
        //int 0 (右键1 中键2)
        if (Input.GetMouseButton(0))
        {
        }

        //鼠标左键按下瞬间
        if (Input.GetMouseButtonDown(0))
        {
        }

        //鼠标左键抬起瞬间
        if (Input.GetMouseButtonUp(0))
        {
        }
    }

原创内容,转载请注明出处

http://www.cnblogs.com/777777-716/p/5003962.html 

相关文章:

  • 2021-12-02
  • 2022-12-23
  • 2021-12-09
  • 2021-11-06
  • 2021-09-16
  • 2021-11-18
猜你喜欢
  • 2021-06-25
  • 2021-07-13
  • 2021-12-07
  • 2021-07-29
  • 2021-05-15
  • 2021-05-20
  • 2021-08-27
相关资源
相似解决方案