Unity 鼠标双击

来源:互联网 发布:老板的红颜知已 编辑:程序博客网 时间:2024/04/30 08:57
using UnityEngine;using System.Collections;public class SlideScreen : MonoBehaviour{    bool one_click = false;    bool timer_running;    float timer_for_double_click;    float delay;    //public Vector3 position;    void Start()    {    }    // Update is called once per frame    void Update()    {        if (Input.GetMouseButtonDown(0))        {            if (!one_click) // first click no previous clicks            {                one_click = true;                timer_for_double_click = Time.time; // save the current time                                                    // do one click things;            }            else            {                one_click = false; // found a double click, now reset                //do double click things            }        }        if (one_click)        {            // if the time now is delay seconds more than when the first click started.             if ((Time.time - timer_for_double_click) > delay)            {                //basically if thats true its been too long and we want to reset so the next click is simply a single click and not a double click.                one_click = false;            }        }    }}
原创粉丝点击