private void Removewarehouse(CoroutineEnumerator c) { if (warehouse.ContainsKey(c.action)) { warehouse[c.action].Remove(c); if (warehouse[c.action].Count <= 0) { warehouse.Remove(c.action); } } }
//按照委托的类来进行添加移除协程 private void Addwarehouse(CoroutineEnumerator c) { if (!warehouse.ContainsKey(c.action)) { warehouse.Add(c.action, new List <CoroutineEnumerator>() { c }); } else { warehouse[c.action].Add(c); } }
public string Run <T1, T2>(CoroutineAction <T1, T2> action, T1 t1, T2 t2) { CoroutineEnumerator c = (CoroutineEnumerator)Main.referencePoolManager.OnSpwn <CoroutineEnumerator>(); c.Fill(action, new object[] { t1, t2 }); c.Run(); if (!coroutineEnumerators.ContainsKey(c.id)) { coroutineEnumerators.Add(c.id, c); } Addwarehouse(c); return(c.id); }
//这里的CoroutineAction只是委托,只需要将方法名填入形参即可,而不是协程方法 public string Run(CoroutineAction action) { CoroutineEnumerator c = (CoroutineEnumerator)Main.referencePoolManager.OnSpwn <CoroutineEnumerator>(); c.Fill(action, null); c.Run(); if (!coroutineEnumerators.ContainsKey(c.id)) { coroutineEnumerators.Add(c.id, c); } Addwarehouse(c); return(c.id); }