Last active
October 20, 2017 16:10
-
-
Save justonia/208085aa1ffd3683e35f30178cbbd0f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using UnityEngine; | |
// Wait for a simple boolean predicate to be true. Example: | |
// | |
// private IEnumerator HandleDeath() { | |
// yield return new WaitWhile(() => hitPoints != 0); | |
// Instantiate(SuperCoolDeathFXPrefab); | |
// } | |
// | |
class WaitWhile : CustomYieldInstruction | |
{ | |
private Func<bool> predicate; | |
public override bool keepWaiting { get { return predicate(); } } | |
public WaitWhile(Func<bool> predicate) { this.predicate = predicate; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment