You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CrowdControl/Assets/3rd/StompyRobot/SRDebugger/Scripts/UI/Controls/MultiTapButton.cs

31 lines
744 B
C#

1 month ago
namespace SRDebugger.UI.Controls
{
using UnityEngine;
using UnityEngine.EventSystems;
public class MultiTapButton : UnityEngine.UI.Button
{
private float _lastTap;
private int _tapCount;
public int RequiredTapCount = 3;
public float ResetTime = 0.5f;
public override void OnPointerClick(PointerEventData eventData)
{
if (Time.unscaledTime - _lastTap > ResetTime)
{
_tapCount = 0;
}
_lastTap = Time.unscaledTime;
_tapCount++;
if (_tapCount == RequiredTapCount)
{
base.OnPointerClick(eventData);
_tapCount = 0;
}
}
}
}