I want to create a List of coroutines to start if future. How to store such functions inside a list?
Say we have a function like:
IEnumerator Example() {
while (true) {
yield return new WaitForFixedUpdate();
}
}
We cant store it inside something like List> list
but we get compiler error like:
Error 1 The best overloaded method match for 'System.Collections.Generic.List<System.Func<System.Collections.IEnumerator>>.Add(System.Func<System.Collections.IEnumerator>)' has some invalid arguments
when we call
list.Add(Example);
or if we use List list
we get no compile errors but on
if (disposeActions.Any()) {
yield return StartCoroutine(list[0]); //here we get null exception
disposeActions.RemoveAt(0);
}
So I wonder how to create a list to store IEnumerator functions and be capable to send its items to coutines?