Beispiel #1
0
        private void UpdateCompleteDownloadRequests()
        {
            foreach (string key in m_completeDownloadAssetBundles)
            {
                TEDDebug.LogFormat("[AssetBundleSystem] - 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)
                {
                    TEDDebug.LogFormat("[AssetBundleSystem] - 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());
        }
Beispiel #2
0
        public void Download(Action <AssetBundleDownloadProgress> onAssetBundleDownloadProgressChanged)
        {
            m_onAssetBundleDownloadProgressChanged = onAssetBundleDownloadProgressChanged;

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

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

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

            var allAssetBundles          = m_assetBundleManifest.GetAllAssetBundles();
            var 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));
        }