unity 获取鼠标跟键盘

unity3D鼠标的获取

 

 自己可以试验一下看看打印出来的值

//获取鼠标屏幕的的滑动跟移动的函数
        float aa = Input.GetAxis("Mouse ScrollWheel") * 1f;//鼠标滚轮
        float bb = Input.GetAxis("Mouse X");//鼠标的左右移动
        float cc = Input.GetAxis("Mouse Y");//鼠标的上下移动
 if (aa !=0)
        {
            Debug.Log(aa);
        }
        else if (bb !=0)
        {
            Debug.Log(bb );
        }
        else if (cc !=0)
        {
            Debug.Log(cc);
        }

unity3D键盘的获取

  //获取键盘的输入 (直上直下) 0-- -1的输入float moveh = Input.GetAxis("Horizontal");
        float movev = Input.GetAxis("Vertical");
        transform.Translate(new Vector3(moveh, 0, movev) * Time.deltaTime * speed);​

 

posted @ 2019-09-02 13:49  剑起苍穹  阅读(1098)  评论(0编辑  收藏  举报
/*鼠标点击特效*/