Skip to content

Instantly share code, notes, and snippets.

@vladpazych
Last active March 12, 2018 15:45
Show Gist options
  • Select an option

  • Save vladpazych/d784a65ff94a3a4acab9783aa1af00ec to your computer and use it in GitHub Desktop.

Select an option

Save vladpazych/d784a65ff94a3a4acab9783aa1af00ec to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
public class CoroutineManager : MonoBehaviour {
private CoroutineManager () {
_instance = this;
}
private static CoroutineManager _instance;
public static CoroutineManager instance {
get {
if (_instance == null) {
_instance = new GameObject ().AddComponent<CoroutineManager> ();
_instance.gameObject.name = "CoroutineManager";
DontDestroyOnLoad (_instance);
}
return _instance;
}
}
public Coroutine Run (IEnumerator routine) {
if (routine == null) return null;
return StartCoroutine (routine);
}
public void Break (IEnumerator routine) {
StopCoroutine (routine);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment