UnityAPI——Input

 

GetKey

按注按键的时候会一直返回true

GetKeyDown

只会在按下按键的时候返回true

GetKeyUp

只会在抬起的时候返回true

         if (Input.GetKey(KeyCode.A))
        {
            Debug.Log("a");
        }

        if (Input.GetKeyDown(KeyCode.B))
        {
            Debug.Log("b");
        }

        if (Input.GetKeyUp(KeyCode.C))
        {
            Debug.Log("c");
        }

 Input.GetMouseButton(int button)

        鼠标的监听,0代表鼠标左键,1代表鼠标右键,2代表鼠标中键

GetButton

        根据提前提前设置的虚拟按键来做一个监听

GetAxis

        返回的是浮点类型,取得轴的值,范围是从0到1,另外一个方向是从0到-1,可以模拟加速移动

        float move = Input.GetAxis("Horizontal");
        this.transform.Translate(Vector3.forward * Time.deltaTime * move);

GetAxisRaw

        无渐变效果直接变为1,另一个方向是-1

GetTouch

        检测是否有触摸(插件,easytouch)

anykey

        按下任何键都会返回true

mousePosition

        以像素为单位,左下角为坐标原点,返回鼠标的坐标

Debug.Log(Input.mousePosition);

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值