Last active
February 5, 2020 23:47
-
-
Save hk1ll3r/17c0b006e5ca7466d8559af2494aaff8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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