Skip to content

Instantly share code, notes, and snippets.

@hk1ll3r
Created February 5, 2020 23:23
Show Gist options
  • Save hk1ll3r/76a13d6dbb567e36b856a9a586249965 to your computer and use it in GitHub Desktop.
Save hk1ll3r/76a13d6dbb567e36b856a9a586249965 to your computer and use it in GitHub Desktop.
public class MyMonoBehaviour : MonoBehaviour {
protected IEnumerator DelayedCoroutine(float delay, System.Action a)
{
yield return new WaitForSecondsRealtime(delay);
a();
}
protected Coroutine RunDelayed(float delay, System.Action a)
{
return StartCoroutine(DelayedCoroutine(delay, a));
}
}
public class Buff : MyMonoBehaviour
{
public void OnBuff()
{
StopAllCoroutines();
Debug.Log("buffed!");
RunDelayed(2f, () => {
Debug.Log("debuffed!");
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment