纳金网

标题: 鼠标双击的获取! [打印本页]

作者: 宁唯是宁唯    时间: 2013-9-23 10:33
标题: 鼠标双击的获取!
挣一点金币
  1. public class test : MonoBehaviour
  2. {
  3.     public float doubeClickDelay = 0.4f;
  4.     bool firstClick = false;
  5.     bool secondClick = false;
  6.     float firstClickTime;
  7.     float secondClickTime;

  8.     // Use this for initialization
  9.     void Start()
  10.     {

  11.     }

  12.     // Update is called once per frame
  13.     void Update()
  14.     {

  15.         if (Time.time - firstClickTime > doubeClickDelay)
  16.         {
  17.             firstClick = false;
  18.             secondClick = false;
  19.         }
  20.     }

  21.     void OnMouseUp()
  22.     {
  23.         print("up!!");
  24.         if (firstClick == false)
  25.         {
  26.             firstClick = true;

  27.             firstClickTime = Time.time;
  28.             return;
  29.         }
  30.         if (firstClick)
  31.         {
  32.             secondClick = true;
  33.             secondClickTime = Time.time;
  34.             
  35.             print("double Click!!!!!!!!!!");
  36.         }

  37.     }
  38. }
复制代码

作者: 王者再临    时间: 2013-9-23 10:46
不错的分享,谢谢了!
作者: 幸福小猪    时间: 2013-10-28 11:00
感谢楼主分享
作者: fkun.lam    时间: 2013-10-31 09:20
不错的分享,谢谢了!
作者: zhangzhen551    时间: 2013-11-12 07:55
非常实用,顶起来!!




欢迎光临 纳金网 (http://go.narkii.com/club/) Powered by Discuz! X2.5