using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CoroutineManager : SingletonTemplate<CoroutineManager>
{
private Dictionary<string, IEnumerator> ieDic = new Dictionary<string, IEnumerator>();
public void StartCorotine(string name, IEnumerator ie)
{
if (ieDic.ContainsKey(name)) return;
ieDic.Add(name, ie);
GameManager.inst.StartCoroutine(ie);
}
public void StopCorotine(string name)
{
if (!ieDic.ContainsKey(name)) return;
IEnumerator cor = ieDic[name];
GameManager.inst.StopCoroutine(cor);
ieDic.Remove(name);
}
public void Clear()
{
foreach (var v in ieDic)
{
GameManager.inst.StopCoroutine(v.Value);
}
ieDic.Clear();
}
}
网友评论