private static IEnumerator delayer(Transport.FlatBuffers.StateUpdate passedUpdate, Action <Transport.FlatBuffers.StateUpdate> action) { yield return(delay); if (action != null) { action.Invoke(passedUpdate); } }
public static void Debounce(this Transport.FlatBuffers.StateUpdate update, MonoBehaviour caller, Action <Transport.FlatBuffers.StateUpdate> toDo, bool isSceneChangeAction) { if (isSceneChangeAction) { if (sceneChangeCoroutine != null) { caller.StopCoroutine(sceneChangeCoroutine); } sceneChangeAction = toDo; delayedCoroutine = caller.StartCoroutine(delayer(update, sceneChangeAction)); } else { if (delayedCoroutine != null) { caller.StopCoroutine(delayedCoroutine); } finalAction = toDo; delayedCoroutine = caller.StartCoroutine(delayer(update, finalAction)); } }