Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
using UnityEngine;
using System.Collections;
public class CachingLoadExample : MonoBehaviour
public string BundleURL;
public string AssetName;
public int version;
void Start ()
StartCoroutine (DownloadAndCache ());
IEnumerator DownloadAndCache ()
while (!Caching.ready)
yield return null;
using (WWW www = WWW.LoadFromCacheOrDownload (BundleURL, version)) {
yield return www;
if (www.error != null) {
throw new UnityException ("WWW download had an error" + www.error);
AssetBundle bundle = www.assetBundle;
if (AssetName == "") {
Instantiate (bundle.mainAsset);
} else {
Instantiate (bundle.LoadAsset (AssetName));
bundle.Unload (false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment