Type not resolved because of a cycle

function ObjectiveCompleted ()

function DiplayGameOver ( succeed : boolean )


Something to do with the yield is causing the following error, but can someone tell me why?

BCE0070: Definition of ‘GameController.ObjectiveCompleted()’ depends on ‘Gameover_Screen.DiplayGameOver(boolean)’ whose type could not be resolved because of a cycle. Explicitly declare the type of either one to break the cycle.

Make ObjectiveCompleted explicitly return void, or make DisplayGameOver explicitly return IEnumerator, as the error says. However, if you get errors like this, you’re probably doing recursion when you shouldn’t be, so I’d recommend restructuring your code to omit the recursion instead.

In C#, coroutines (anything with yield in it) MUST use yield at least once.

When DisplayGameOver runs it might yield or it might never run the loop and not yield (we know the loop will run, since alpha start below 1, but the compiler doesn’t.) So, the compiler can’t tell whether to use javaScript magic and turn it into a coroutine.

I’m thinking that just adding a single yield after the loop might fix it (that’s how you fix the error C# would give you.)