找回密码
 立即注册
查看: 6149|回复: 80

[基础] unity鼠标双击事件

[复制链接]
发表于 2014-10-7 14:21 | 显示全部楼层 |阅读模式
资源信息 Tutorial Information
教程名称: unity鼠标双击事件(发帖教程)
适用引擎:   (适用引擎,为空默认为Unity)
教程语种: 中文
教程等级: 1
教程格式: 图文(请用IE9以上浏览器访问本版块)
教程作者: 转载自互联网 (如有问题请短消息联系作者或发表回复)
下载地址: (兑换积分)
点击查看原图
美丽分割线
我就直接上代码   大概原理就是通过第一次点击的时间跟第二次点击的时间进行相减 如果小于 0.2s 就判断为双击  
很简单的一个鼠标双击的判断


using UnityEngine;


namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Input)]
[Tooltip("Gets the pressed state of the specified Mouse Button and stores it in a Bool Variable. See Unity Input Manager doc.")]
public class GetMouseDLeft : FsmStateAction
{

        [RequiredField]
        public MouseButton button;
        public FsmEvent sendEvent;
        [UIHint(UIHint.Variable)]
        public FsmBool storeResult;
float time=0;
int count=0;
public override void Reset()
{
            button = MouseButton.Left;
            sendEvent = null;
            storeResult = null;
}


public override void OnUpdate()
{
bool buttonDown = Input.GetMouseButtonDown((int)button);
if (buttonDown)
{
if(count==0)
time=Time.time;
count++;
}
if (count == 2)
{
if((Time.time-time)<0.2)
{
if (buttonDown)
Fsm.Event(sendEvent);
storeResult.Value = buttonDown;
count=0;
time=0;
}
else
{
count=0;
time=0;
}
}
}
}
}
这个是我在Taikr学习的一些经验,现在在做活动

发现个不错的U3d视频的地方,正在做活动,大部分课程都免费。RPG游戏,跑酷游戏,局域网CS游戏,nGUI全都是中文视频。http://www.taikr.com/group/5/thread/284

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
发表于 2017-3-20 11:04 | 显示全部楼层
楼主是超人
发表于 2017-3-20 11:08 | 显示全部楼层
好帖就是要顶
发表于 2017-3-20 10:29 | 显示全部楼层
真心顶
发表于 2017-3-20 10:37 | 显示全部楼层
很好哦
发表于 2017-3-20 10:53 | 显示全部楼层
不错不错
发表于 2017-3-21 09:46 | 显示全部楼层
好帖就是要顶
发表于 2017-3-21 09:12 | 显示全部楼层
顶顶多好
发表于 2017-3-21 09:47 | 显示全部楼层
说的非常好
发表于 2017-3-21 09:53 | 显示全部楼层
很好哦
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Unity开发者联盟 ( 粤ICP备20003399号 )

GMT+8, 2024-5-12 10:23 , Processed in 0.112211 second(s), 32 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表