I am working with coroutines, and wondering if there is any difference between these two different usages:
public void Update()
{
yield return M();
yield return StartCoroutine(M());
}
public IEnumerator M()
{
// ....
}
I am working with coroutines, and wondering if there is any difference between these two different usages:
public void Update()
{
yield return M();
yield return StartCoroutine(M());
}
public IEnumerator M()
{
// ....
}
This is no longer the case after an update during 5.3. Unity 5.4.0 onwards creates a coroutine internally if an IEnumerator value is yield return.
yield return M();
and
yield return StartCoroutine(M());
Will now behave the same and run the full function M as a coroutine.
Yes.
yield return M();
is the same then yield return null;. It won’t start the Coroutine and yield for one frame.
yield return StartCoroutine(M());
will wait that the coroutine has completed before resuming your function that called it.
Note: You can’t “yield” in Update.