Skip to content

Instantly share code, notes, and snippets.

@is8r
Created November 17, 2016 10:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save is8r/7561e2b0d1d4da0d31f9cee22ca5a022 to your computer and use it in GitHub Desktop.
Save is8r/7561e2b0d1d4da0d31f9cee22ca5a022 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
using System;
using System.Collections.Generic;
public static class MonoBehaviorExtentsion
{
public static IEnumerator DelayMethod<T>(this MonoBehaviour mono, float waitTime, Action<T> action, T t)
{
yield return new WaitForSeconds(waitTime);
action(t);
}
public static IEnumerator DelayMethod(this MonoBehaviour mono, float waitTime, Action action)
{
yield return new WaitForSeconds(waitTime);
action();
}
public static Coroutine Delay<T>(this MonoBehaviour mono, float waitTime, Action<T> action, T t)
{
return mono.StartCoroutine(DelayMethod(mono, waitTime, action, t));
}
public static Coroutine Delay(this MonoBehaviour mono, float waitTime, Action action)
{
return mono.StartCoroutine(DelayMethod(mono, waitTime, action));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment