private void SetupLongPress(KMSelectable selectable, float time, Action press, Action longPress) { var held = false; IEnumerator LongPress() { yield return(new WaitForSeconds(time)); held = true; longPress(); } Coroutine pressCoroutine = null; selectable.OnInteract = () => { held = false; pressCoroutine = selectable.StartCoroutine(LongPress()); return(false); }; selectable.OnInteractEnded = () => { if (pressCoroutine == null || held) { return; } selectable.StopCoroutine(pressCoroutine); press(); }; }