Ejemplo n.º 1
0
        private void UpdateCompleteDownloadRequests()
        {
            foreach (string key in m_completeDownloadAssetBundles)
            {
                JSLDebug.LogFormat("[AssetBundleManager] - Download asset bundle '{0}' successfully at frame {1}", key, Time.frameCount);

                m_cacheRequest = m_downloadingRequests[key];
                m_cacheRequest.Dispose();
                m_downloadingRequests.Remove(key);
            }

            if (m_assetBundleDownloadProgress != null)
            {
                m_assetBundleDownloadProgress.SetDownloadCount(m_downloadingRequests.Count + m_waitingDownloadRequests.Count);

                if (m_assetBundleDownloadProgress.progress == 1)
                {
                    JSLDebug.LogFormat("[AssetBundleManager] - Download AssetBundle complete at frame {0}", Time.frameCount);
                    ResourceManager.Instance.Clear();
                }

                if (m_onAssetBundleDownloadProgressChanged != null)
                {
                    m_onAssetBundleDownloadProgressChanged(m_assetBundleDownloadProgress);
                }
            }

            if (m_downloadingRequests.Count == 0 && m_waitingDownloadRequests.Count == 0)
            {
                m_onAssetBundleDownloadProgressChanged = null;
                m_assetBundleDownloadProgress          = null;
            }

            m_inProgressRequests.RemoveAll(request => !request.Update());
        }
Ejemplo n.º 2
0
        public void Download(Action <AssetBundleDownloadProgress> onAssetBundleDownloadProgressChanged)
        {
            m_onAssetBundleDownloadProgressChanged = onAssetBundleDownloadProgressChanged;

            if (m_assetBundleLoadType == AssetBundleLoadType.Simulate)
            {
                JSLDebug.LogFormat("[AssetBundleManager] - The AssetBundle load type is on Simulate, don't need to download.");
                return;
            }

            if (null == m_assetBundleManifest)
            {
                JSLDebug.LogError("[AssetBundleManager] - Please download AssetBundleManifest by calling ResourceSystem.InstancenitAssetBundle() first");
                return;
            }

            JSLDebug.LogFormat("[AssetBundleManager] - Start download AssetBundle at frame {0}", Time.frameCount);

            string[]      allAssetBundles          = m_assetBundleManifest.GetAllAssetBundles();
            List <string> downloadAssetBundleNames = new List <string>();

            for (int i = 0; i < allAssetBundles.Length; i++)
            {
                if (Caching.IsVersionCached(m_downloadingURL + allAssetBundles[i], m_assetBundleManifest.GetAssetBundleHash(allAssetBundles[i])))
                {
                    continue;
                }

                downloadAssetBundleNames.Add(allAssetBundles[i]);
            }

            UnloadAssetBundles(allAssetBundles.ToList());

            for (int i = 0; i < allAssetBundles.Length; i++)
            {
                DownloadAssetBundle(allAssetBundles[i], false);
            }

            m_assetBundleDownloadProgress = new AssetBundleDownloadProgress(allAssetBundles.Length, m_assetBundleCatalogs.GetAllFileSize(downloadAssetBundleNames));
        }