protected static bool LoadAssetBundleInternal(string assetBundleName, bool isLoadingAssetBundleManifest)
{
// Already loaded.
LoadedAssetBundle bundle = null;
m_LoadedAssetBundles.TryGetValue(assetBundleName, out bundle);
if (bundle != null)
{
bundle.m_ReferencedCount++;
return true;
}
// @TODO: Do we need to consider the referenced count of WWWs?
// In the demo, we never have duplicate WWWs as we wait LoadAssetAsync()/LoadLevelAsync() to be finished before calling another LoadAssetAsync()/LoadLevelAsync().
// But in the real case, users can call LoadAssetAsync()/LoadLevelAsync() several times then wait them to be finished which might have duplicate WWWs.
if (m_DownloadingWWWs.ContainsKey(assetBundleName) )
return true;
WWW download = null;
string url = m_BaseDownloadingURL + assetBundleName;
// For manifest assetbundle, always download it as we don't have hash for it.
if (isLoadingAssetBundleManifest)
download = new WWW(url);
else
download = WWW.LoadFromCacheOrDownload(url, m_AssetBundleManifest.GetAssetBundleHash(assetBundleName), 0);
m_DownloadingWWWs.Add(assetBundleName, download);
return false;
}