Skip to content

Instantly share code, notes, and snippets.

@FlaShG FlaShG/CoroutineWorker.cs
Last active Sep 25, 2018

What would you like to do?
Based on MyStaticCode.cs, a class that allows anything to run coroutines from anywhere.
using UnityEngine;
using System.Collections;
public static class CoroutineWorker
private class Worker : MonoBehaviour { }
private static Worker worker;
private static void Initialize()
var go = new GameObject("Coroutine Worker");
worker = go.AddComponent<Worker>();
go.hideFlags = HideFlags.HideAndDontSave;
public static Coroutine StartCoroutine(IEnumerator routine)
return worker.StartCoroutine(routine);
public static void StopCoroutine(Coroutine routine)
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.