Skip to content

Instantly share code, notes, and snippets.

@is8r is8r/DelayUtil.cs
Created Nov 17, 2016

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
You can’t perform that action at this time.