您当前的位置: 首页 >  unity

程序员正茂

暂无认证

  • 3浏览

    0关注

    283博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Unity 单击双击的判断

程序员正茂 发布时间:2019-05-15 16:16:02 ,浏览量:3

 

private float tapThreshold = 0.25f;
    private float tapTimer = 0.0f;
    private bool tap = false;
    private void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            if (Time.time < this.tapTimer + this.tapThreshold)
            {
                Debug.Log("双击");
                this.tap = false;
                return;
            }
            this.tap = true;
            this.tapTimer = Time.time;
        }
        if (this.tap == true && Time.time > this.tapTimer + this.tapThreshold)
        {
            this.tap = false;
            Debug.Log("单击");           
        }
    }

 

关注
打赏
1660743125
查看更多评论
立即登录/注册

微信扫码登录

0.0356s