Skip to content

Instantly share code, notes, and snippets.

@justonia
Last active October 20, 2017 16:10
Show Gist options
  • Save justonia/208085aa1ffd3683e35f30178cbbd0f6 to your computer and use it in GitHub Desktop.
Save justonia/208085aa1ffd3683e35f30178cbbd0f6 to your computer and use it in GitHub Desktop.
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