Skip to content

Instantly share code, notes, and snippets.

@pr00thmatic
Last active March 9, 2019 11:16
Show Gist options
  • Save pr00thmatic/164c682f0e73fb9b1b8588d0ac762cc8 to your computer and use it in GitHub Desktop.
Save pr00thmatic/164c682f0e73fb9b1b8588d0ac762cc8 to your computer and use it in GitHub Desktop.
using UnityEngine;
// use it like this:
// yield return new PauseFriendlyWaitForSeconds(1.3f);
public class PauseFriendlyWaitForSeconds : CustomYieldInstruction {
float elapsed = 0;
float waitingTime;
public override bool keepWaiting {
get {
elapsed += GameController.Instance.IsPaused? 0: Time.deltaTime;
return elapsed < waitingTime;
}
}
public PauseFriendlyWaitForSeconds (float waitingTime) {
elapsed = 0;
this.waitingTime = waitingTime;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment