Is WWW.LoadFromCacheOrDownload() a synchronous function or asynchronous function when it loading asset bundle from cache?
I have a test code :
www = WWW.LoadFromCacheOrDownload(path, DEFAULT_VERSION);//path with version is cached in advance.
Debug.Log("www.isDone: " +www.isDone);//outputs: www.isDone:False
AssetBundle ab = www.assetBundle;//But if I break the code here, www.isDone = Ture
Async. It instantiates the WWW, and when WWW is instantiated, it makes a call to the server. With the exception that using this method checks the cache and downloads from there if available.
You should always treat your WWW calls asynchronously, by using either:
coroutines (with yield return)
checking www.isDone within your Update method
using a lib like eDriven which enables writing your code in the callback (non-blocking) fashion
The way you use the 3rd option is:
private readonly HttpConnector _httpConnector = new HttpConnector();
// in your Start() method:
_httpConnector.Send(
_yourUrl,
delegate (object data)
{
WWW w = (WWW)data;
/// w.isDone is true. Process data...
}
);