Unity 鼠标双击

xiaoxiao2021-02-28  93

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; } } } }
转载请注明原文地址: https://www.6miu.com/read-23372.html

最新回复(0)