void Update()
        {
            // Collect all the finished WWWs.
            var keysToRemove = new List <string>();

            foreach (var keyValue in m_LoadingAssetBundles)
            {
                WWW download = keyValue.Value.m_DownloadingWWW;
                if (download == null)
                {
                    continue;
                }

                // If downloading fails.
                if (download.error != null)
                {
                    m_DownloadingErrors.Add(keyValue.Key, string.Format("Failed downloading bundle {0} from {1}: {2}", keyValue.Key, download.url, download.error));
                    keysToRemove.Add(keyValue.Key);
                    continue;
                }

                // If downloading succeeds.
                if (download.isDone)
                {
                    AssetBundle bundle = download.assetBundle;
                    if (bundle == null)
                    {
                        m_DownloadingErrors.Add(keyValue.Key, string.Format("{0} is not a valid asset bundle.", keyValue.Key));
                        keysToRemove.Add(keyValue.Key);
                        continue;
                    }

                    if (!m_LoadedAssetBundles.ContainsKey(keyValue.Key))
                    {
                        m_LoadedAssetBundles.Add(keyValue.Key, new LoadedAssetBundle(download.assetBundle));
                    }
                    else
                    {
                        m_LoadedAssetBundles[keyValue.Key] = new LoadedAssetBundle(download.assetBundle);
                    }

                    keysToRemove.Add(keyValue.Key);

                    if (keyValue.Value.m_Action_Complete_Download != null)
                    {
                        keyValue.Value.m_Action_Complete_Download();
                    }
                }
            }

            // Remove the finished WWWs.
            foreach (var key in keysToRemove)
            {
                LoadingAssetBundle _loadingBundle = m_LoadingAssetBundles[key];
                WWW download = _loadingBundle.m_DownloadingWWW;
                download.Dispose();
                m_LoadingAssetBundles.Remove(key);
            }
        }
        public bool LoadAssetBundleInternal(string assetBundleName, System.Action _completeDownloadCallBack)
        {
            // Already loaded.
            LoadedAssetBundle bundle = null;

            m_LoadedAssetBundles.TryGetValue(assetBundleName, out bundle);
            if (bundle != null)
            {
                bundle.m_ReferencedCount++;
                return(true);
            }

            LoadingAssetBundle _loadingBundle = null;

            m_LoadingAssetBundles.TryGetValue(assetBundleName, out _loadingBundle);
            if (_loadingBundle != null)
            {
                if (_completeDownloadCallBack != null)
                {
                    _loadingBundle.m_Action_Complete_Download += _completeDownloadCallBack;
                }
                return(true);
            }

            _loadingBundle = new LoadingAssetBundle(assetBundleName);
            if (_completeDownloadCallBack != null)
            {
                _loadingBundle.m_Action_Complete_Download += _completeDownloadCallBack;
            }
            m_LoadingAssetBundles.Add(assetBundleName, _loadingBundle);
            string url = m_BaseDownloadingURL + assetBundleName;

            _loadingBundle.m_DownloadingWWW = WWW.LoadFromCacheOrDownload(url, 1);

            return(false);
        }