function foo()
{
yield WaitForSeconds(1);
...
foo();
}
But I get the error
BCE0070: Definition of 'Script.foo' depends on 'Script.foo' whose type could not be resolved because of a cycle. Explicitly declare the type of either one to break the cycle.
I had a look around for the error code and had a read of the yield pages on the docs but I can't make sense of it. How can I create a loop like the above?
Generally you shouldn't use recursion unless you actually need it, but just to answer the specific question here, the type of a coroutine is IEnumerator. So you can use
function foo() : IEnumerator
to fix the error message, though using an infinite loop is better in this case.