Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void InstallGameFiles(bool _isUpdate, Version _onlineVersion)
- {
- try
- {
- _downloadBar.gameObject.SetActive(true);
- _downloadBar.maxValue = 100f;
- _downloadSpeed.gameObject.SetActive(true);
- _downloadSize.gameObject.SetActive(true);
- _executionText.gameObject.SetActive(true);
- /////////////////////Stopwatch watch = new Stopwatch();
- watch.Start();
- WebClient webClient = new();
- webClient.Proxy = null;
- webClient.DownloadProgressChanged += (sender, e) =>
- {
- double index = (double)(e.BytesReceived);
- double total = (double)e.TotalBytesToReceive;
- double progressPercentage = (index / total);
- float iProgressPercentage = (float)(progressPercentage * 100);
- if(_downloadBar != null)
- _downloadBar.value = iProgressPercentage;
- double sec = watch.Elapsed.TotalSeconds;
- double speed = e.BytesReceived / sec;
- _downloadSpeed.text = SizeSuffix((long)speed) + "/s";
- _downloadSize.text = SizeSuffix(e.BytesReceived) + "/" + SizeSuffix(e.TotalBytesToReceive);
- };
- webClient.DownloadFileCompleted += (sender, e) =>
- {
- DownloadGameCompleteCallback(sender, e);
- /////////////////watch.Stop();
- //////////////DEBUG
- };
- webClient.DownloadFileAsync(new Uri(gameBuildZipLink), gameZip, _onlineVersion);
- }
- catch (Exception ex)
- {
- MsgBox(0, $"Error downloading the game: {ex}", "Error", 0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment