Ejemplo n.º 1
0
        public Coroutine StartTaskCoroutine(Task task, string methodName, object value)
        {
            MethodInfo method = task.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            if (method == null)
            {
                Debug.LogError("Unable to start coroutine " + methodName + ": method not found");
                return(null);
            }
            if (this.activeTaskCoroutines == null)
            {
                this.activeTaskCoroutines = new Dictionary <string, List <TaskCoroutine> >();
            }
            TaskCoroutine taskCoroutine = new TaskCoroutine(this, (IEnumerator)method.Invoke(task, new object[]
            {
                value
            }), methodName);

            if (this.activeTaskCoroutines.ContainsKey(methodName))
            {
                List <TaskCoroutine> list = this.activeTaskCoroutines[methodName];
                list.Add(taskCoroutine);
                this.activeTaskCoroutines[methodName] = list;
            }
            else
            {
                List <TaskCoroutine> list2 = new List <TaskCoroutine>();
                list2.Add(taskCoroutine);
                this.activeTaskCoroutines.Add(methodName, list2);
            }
            return(taskCoroutine.coroutine);
        }
Ejemplo n.º 2
0
 public void TaskCoroutineEnded(TaskCoroutine taskCoroutine, string coroutineName)
 {
     if (this.activeTaskCoroutines.ContainsKey(coroutineName))
     {
         List <TaskCoroutine> list = this.activeTaskCoroutines[coroutineName];
         if (list.Count == 1)
         {
             this.activeTaskCoroutines.Remove(coroutineName);
         }
         else
         {
             list.Remove(taskCoroutine);
             this.activeTaskCoroutines[coroutineName] = list;
         }
     }
 }