26 lines
655 B
C#
26 lines
655 B
C#
using UnityEngine;
|
|
|
|
public static class InteractionClickGuard
|
|
{
|
|
private static int _lastHandledFrame = -1;
|
|
private static float _lastHandledTime = -1f;
|
|
|
|
public static void MarkHandled()
|
|
{
|
|
_lastHandledFrame = Time.frameCount;
|
|
_lastHandledTime = Time.unscaledTime;
|
|
}
|
|
|
|
public static bool WasHandledThisFrame()
|
|
{
|
|
return _lastHandledFrame == Time.frameCount;
|
|
}
|
|
|
|
public static bool WasHandledRecently()
|
|
{
|
|
return Time.frameCount - _lastHandledFrame <= 1 ||
|
|
(Time.unscaledTime - _lastHandledTime >= 0f &&
|
|
Time.unscaledTime - _lastHandledTime <= 0.1f);
|
|
}
|
|
}
|