IEnumerator HoldButtonForSeconds(KeyCode key, float seconds, Util.VoidFunction action) { float endTime = Time.time + seconds; while (Time.time <= endTime) { if (!Input.GetKey(key)) { yield break; } yield return(null); } action(); }
IEnumerator WaitForPlayerToLeave(float seconds, Util.VoidFunction action) { float endTime = Time.time + seconds; while (endTime < Time.time) { if (playerIsNear) { endTime = Time.time + seconds; } yield return(null); } action(); }
public static void SetTimeout(this MonoBehaviour mb, Util.VoidFunction action, float seconds) { mb.StartCoroutine(Util.setTimeoutHelper(action, seconds)); }