- 最后登录
- 2021-7-6
- 注册时间
- 2012-12-27
- 阅读权限
- 90
- 积分
- 76145
- 纳金币
- 53464
- 精华
- 316
|
大概原理就是通过第一次点击的时间跟第二次点击的时间进行相减 如果小于 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;
}
}
}
}
}
|
|