AssetBundles.AssetBundleManager.LoadAssetBundleInternal C# (CSharp) Method

LoadAssetBundleInternal() protected static method

protected static LoadAssetBundleInternal ( string assetBundleName, bool isLoadingAssetBundleManifest ) : bool
assetBundleName string
isLoadingAssetBundleManifest bool
return bool
        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;
        }

Usage Example

Beispiel #1
0
 protected static void LoadAssetBundle(string assetBundleName, bool isLoadingAssetBundleManifest = false)
 {
     if (!isLoadingAssetBundleManifest && AssetBundleManager.m_AssetBundleManifest == null)
     {
         return;
     }
     if (!AssetBundleManager.LoadAssetBundleInternal(assetBundleName, isLoadingAssetBundleManifest) && !isLoadingAssetBundleManifest)
     {
         AssetBundleManager.LoadDependencies(assetBundleName);
     }
 }
All Usage Examples Of AssetBundles.AssetBundleManager::LoadAssetBundleInternal