Guest User

Untitled

a guest
Oct 21st, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. using System;
  2. using UnityEngine;
  3.  
  4. // Wait for a simple boolean predicate to be true. Example:
  5. //
  6. // private IEnumerator HandleDeath() {
  7. // yield return new WaitWhile(() => hitPoints != 0);
  8. // Instantiate(SuperCoolDeathFXPrefab);
  9. // }
  10. //
  11. class WaitWhile : CustomYieldInstruction
  12. {
  13. private Func<bool> predicate;
  14.  
  15. public override bool keepWaiting { get { return predicate(); } }
  16.  
  17. public WaitWhile(Func<bool> predicate) { this.predicate = predicate; }
  18. }
Add Comment
Please, Sign In to add comment