|
Name | Description |
---|---|
string | url The URL to download the data from (if it is not cached). @paramint version Version of the data. The file will only be loaded from the disk cache if it has previously been downloaded with the same version parameter. This lets you force clients to re-download updated data from the network. |
WWW - a WWW instance, which can be used to access the data once the operation is completed. * var www = WWW.LoadFromCacheOrDownload("http://myserver.com/myassetBundle.unity3d", 5); * * yield www; * * if (www.error != null) * { * Debug.Log(www.error); * return null; * } * var myLoadedAssetBundle = www.assetBundle;
Loads an assetBundle from the cache, or downloads it, in case it is not cached.
This works just like "new WWW(url)", with the difference that the download will be written to the disk cache, and only be actually performed if the AssetBundle is not already cached. Unlike "new WWW()", this can only be used to load AssetBundles. A cached asset bundle is identified by the name / the last path component of the url. If a cached asset does not yet exist, or the version number for the cached asset does not match exactly, it will be downloaded and stored in the cache along with the version number provided by the version parameter. Since cached asset bundles are identified by name instead of full url, you can change the directory from where the asset bundle is downloaded at any time. This is useful for pushing out new versions of the game and ensuring that files are not cached incorrectly by the browser or by a CDN. If the cache folder does not have any space for caching additional files, LoadFromCacheOrDownload will try to delete the least-recently-used AssetBundle from the Cache. If making space is not possible (because the hard disk is full, or all files in the cache are in use), LoadFromCacheOrDownload() will simply download the file to memory like a normal "new WWW()" call.