I have 30+ javascript files (I’m not the author) that I’ve already converted to C#; up until now I commented out the yield statements but now I’ll need to implement them. There are functions which have Yield statements that call other functions that have yield statements that call others, etc. Other times I have RPC functions calling functions that have yield.
My main problem I want to avoid is multiple calls to a function that has "StartCoroutine ( myfunction() ); in it.
Another problem I want to avoid is having callback functions like Update needing bool checks and dummy functions:
void Update()
{
function1();
function2();
function3(); // function 3 has a yield statement and must finish before function4()
function4();
}
I can create a dummy function like UpdateHandler() and use an isDone
bool isDone = true;
void Update()
{
if (isDone)
{
isDone = false;
StartCoroutine(UpdateHandler());
}
}
IEnumerator UpdateHandler()
{
function1();
function2();
yield return StartCoroutine(function3);
function4();
isDone = true;
}
If I do this I’ll have all these ugly handlers and isDone checks. Is this really necessary or is there a better solution?
Thanks!