Ejemplo n.º 1
0
        internal static AssetBundleLoaderBase CreateOwnerAssetBundleLoader(AssetInfo assetInfo)
        {
            BundleInfo bundleInfo = BundleServices.GetBundleInfo(assetInfo);

            return(CreateAssetBundleLoaderInternal(bundleInfo));
        }
Ejemplo n.º 2
0
 public OfflinePlayModeRawFileOperation(BundleInfo bundleInfo, string copyPath) : base(bundleInfo, copyPath)
 {
 }
Ejemplo n.º 3
0
 internal HostPlayModeRawFileOperation(BundleInfo bundleInfo, string copyPath) : base(bundleInfo, copyPath)
 {
 }
Ejemplo n.º 4
0
 internal RawFileOperation(BundleInfo bundleInfo, string copyPath)
 {
     _bundleInfo = bundleInfo;
     CopyPath    = copyPath;
 }
Ejemplo n.º 5
0
 // 验证文件完整性
 public static bool CheckContentIntegrity(BundleInfo bundleInfo)
 {
     return(CheckContentIntegrity(bundleInfo.GetCacheLoadPath(), bundleInfo.SizeBytes, bundleInfo.CRC));
 }
Ejemplo n.º 6
0
 public HttpDownloader(BundleInfo bundleInfo) : base(bundleInfo)
 {
 }
Ejemplo n.º 7
0
        internal override void Update()
        {
            if (_steps == ESteps.None || _steps == ESteps.Done)
            {
                return;
            }

            if (_steps == ESteps.Check)
            {
                if (_downloadList == null)
                {
                    _steps = ESteps.Done;
                    Status = EOperationStatus.Failed;
                    Error  = "Download list is null.";
                }
                else
                {
                    _steps = ESteps.Loading;
                }
            }

            if (_steps == ESteps.Loading)
            {
                // 检测下载器结果
                _removeList.Clear();
                long downloadBytes = CurrentDownloadBytes;
                foreach (var downloader in _downloaders)
                {
                    downloadBytes += (long)downloader.DownloadedBytes;
                    if (downloader.IsDone() == false)
                    {
                        continue;
                    }

                    BundleInfo bundleInfo = downloader.GetBundleInfo();

                    // 检测是否下载失败
                    if (downloader.HasError())
                    {
                        _removeList.Add(downloader);
                        _loadFailedList.Add(bundleInfo);
                        continue;
                    }

                    // 下载成功
                    _removeList.Add(downloader);
                    CurrentDownloadCount++;
                    CurrentDownloadBytes += bundleInfo.SizeBytes;
                }

                // 移除已经完成的下载器(无论成功或失败)
                foreach (var loader in _removeList)
                {
                    _downloaders.Remove(loader);
                }

                // 如果下载进度发生变化
                if (_lastDownloadBytes != downloadBytes || _lastDownloadCount != CurrentDownloadCount)
                {
                    _lastDownloadBytes = downloadBytes;
                    _lastDownloadCount = CurrentDownloadCount;
                    Progress           = (float)_lastDownloadBytes / TotalDownloadBytes;
                    OnDownloadProgressCallback?.Invoke(TotalDownloadCount, _lastDownloadCount, TotalDownloadBytes, _lastDownloadBytes);
                }

                // 动态创建新的下载器到最大数量限制
                // 注意:如果期间有下载失败的文件,暂停动态创建下载器
                if (_downloadList.Count > 0 && _loadFailedList.Count == 0)
                {
                    if (_isPause)
                    {
                        return;
                    }

                    if (_downloaders.Count < _downloadingMaxNumber)
                    {
                        int index     = _downloadList.Count - 1;
                        var operation = DownloadSystem.BeginDownload(_downloadList[index], _failedTryAgain);
                        _downloaders.Add(operation);
                        _downloadList.RemoveAt(index);
                    }
                }

                // 下载结算
                if (_downloaders.Count == 0)
                {
                    if (_loadFailedList.Count > 0)
                    {
                        string fileName = _loadFailedList[0].BundleName;
                        Error  = $"Failed to download file : {fileName}";
                        _steps = ESteps.Done;
                        Status = EOperationStatus.Failed;
                        OnDownloadFileFailedCallback?.Invoke(fileName);
                        OnDownloadOverCallback?.Invoke(false);
                    }
                    else
                    {
                        // 结算成功
                        _steps = ESteps.Done;
                        Status = EOperationStatus.Succeed;
                        OnDownloadOverCallback?.Invoke(true);
                    }
                }
            }
        }
Ejemplo n.º 8
0
 public AssetBundleFileLoader(BundleInfo bundleInfo) : base(bundleInfo)
 {
 }