Skip to content

Instantly share code, notes, and snippets.

@pr00thmatic
Last active November 2, 2025 02:32
Show Gist options
  • Select an option

  • Save pr00thmatic/f63f2a4369f8f3a681f0ee9e0f070ac1 to your computer and use it in GitHub Desktop.

Select an option

Save pr00thmatic/f63f2a4369f8f3a681f0ee9e0f070ac1 to your computer and use it in GitHub Desktop.
namespace MediumSizedFailure
{
public class FailedHoldDetector : MonoBehaviour
{
public InputActionReference naiveHoldAction;
void OnEnable () => naiveHoldAction.action.performed += HandleHoldPerformed;
void OnDisable () => naiveHoldAction.action.performed -= HandleHoldPerformed;
private void HandleHoldPerformed (InputAction.CallbackContext context)
{
if (context.control.parent is not TouchControl touch)
return; // maybe it's a click or something else, idk...
OnHoldSuccess?.Invoke(touch.position.ReadValue());
}
public UnityEvent<Vector2> OnHoldSuccess { get; private set; } = new();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment