コルーチンを一括管理するマネージャークラスをつくろうとしたけど、IEnumratorのAPIが少なくて、断念したソース
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class CoroutineManager : MonoBehaviour {
private static int coroutineID = 0;
private Dictionary<int, IEnumerator> _dic;
public object GretCurrent (int id)
{
IEnumerator cor = GetCoroutine (id);
if (cor != null)
{
return cor.Current;
}
}
public int Register (IEnumerator coroutine)
{
_dic.Add (coroutineID, coroutine);
coroutineID++;
}
public void Pause (int id)
{
IEnumerator cor = GetCoroutine (id);
if (cor != null)
{
StopCoroutine (cor);
}
}
void Awake () {
coroutineID = 0;
DontDestroyOnLoad (gameObject);
}
private IEnumerator GetCoroutine (int id)
{
IEnumerator cor = null;
_dic.TryGetValue (id, out cor);
return cor;
}
}