/// <summary> /// Wraps a coroutine inside a method that triggers a callback when its done /// </summary> /// <param name="coroutine">the method that will be wrapped</param> /// <param name="callback">the callback</param> /// <returns>the new coroutined wrapped inside the coroutine</returns> private static IEnumerator CallbackWraper(CoroutineDel coroutine, Action callback) { //wait the coroutine to end yield return(coroutine()); //invoke the callback callback(); }
/// <summary> /// Linq like interface that stores all IEnumerators in a given colection of objects /// </summary> /// <param name="colectRoutine">Method that extracts all coroutines</param> /// <returns>a list of coroutines</returns> public static CoroutineDel[] Select <T>(this IList <T> self, Func <T, CoroutineDel> colectRoutine) { //Initialize the result array CoroutineDel[] result = new CoroutineDel[self.Count]; //Colect all routines and store them inside the result array for (int i = 0; i < self.Count; i++) { result[i] = colectRoutine(self[i]); } //return the result array return(result); }