Skip to content

Instantly share code, notes, and snippets.

Created November 17, 2016 10:01
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
* DelayWrapperClass
* Example:
Coroutine coroutine = DelayUtil.Delay (1.0f, () => {
Debug.Log ("DelayedCall");
using UnityEngine;
using System.Collections;
using System;
public class DelayUtil: MonoBehaviour {
private static readonly DelayUtil self;
static DelayUtil()
GameObject go = new GameObject("DelayUtil");
self = go.AddComponent<DelayUtil>();
public static Coroutine Delay(float waitTime, Action action)
return self.StartCoroutine(DelayMethod(waitTime, action));
public static Coroutine Delay<T>(float waitTime, Action<T> action, T t)
return self.StartCoroutine(DelayMethod(waitTime, action, t));
private static IEnumerator DelayMethod(float waitTime, Action action)
yield return new WaitForSeconds (waitTime);
action ();
private static IEnumerator DelayMethod<T>(float waitTime, Action<T> action, T t)
yield return new WaitForSeconds(waitTime);
public static void Stop(Coroutine coroutine)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment