My code:
public class CharacterBehaviour: MonoBehaviour {
bool isExecuting=false;
Action action;
void Start{
action=new Action();
}
void Update{
//Other methods
if(!isExecuting)
{
StartCoroutine(action.execute(out isExecuting));
}
}
public class Action: MonoBehaviour
{
IEnumerator execute(out isExecuting)
{
return YieldReturnNull)();
//Execution
isExecuting=false;
}
public IEnumerator YieldReturnNull()
{
yield return null;
}
}
I am using IEnumerator to start a coroutine right? But I need this out value to do not start a lot of coroutines in Update, just when it finalizes I must start another. The problem it's that I need to return of yield of course in the beggining (The YieldReturnNull method is a trick because IEnumerator does not accept out or ref as parameter in a method returning yield) but it returns for me this error:
The out parameter `isExecuting' must be assigned to before control leaves the current method.
How to solve it? I need to return yield in the beggining and apply the bool in the end. Thanks. :)
Action
in .NET which is a void delegate - you might run into annoying name collisions later. \$\endgroup\$