Skip to content

Instantly share code, notes, and snippets.

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