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);​

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM