'yield return null' VS 'yield return WWW'

Hi,

I call load scene method in StartCoroutine().

ex)

StartCoroutine(LoadLevel());

And there is code what load asset bundle(WWW) in ‘LoadLevel()’.

Until now, I use below code for waiting WWW is ready.

foreach (WWW texData in coverTexData)
{
    yield return texData;
}

But, below code is faster than upper code.

bool _isAllDone = false;
while (!_isAllDone)
{
    _isAllDone = true;
    foreach (WWW texData in coverTexData)
    {
        if (!texData.isDone) { _isAllDone = false; yield return null; }
    }
}

if there is 40 'WWW’s in coverTexData(List), performance difference is 10 times.

why that difference is coming out?

‘yield return null’ VS ‘yield return WWW’

Thanks :slight_smile:

In the first case, the WWW are resolved each at a time. Therefore a second WWW object has to wait for the previous one to complete.

In the second case, each WWW is ‘ticked’ each frame. So there is no sequential condition.