taochangchun 1 неделя назад
Родитель
Сommit
2e26c528db
4 измененных файлов с 35 добавлено и 2 удалено
  1. 2 1
      DownloadManager.cs
  2. 9 1
      DownloadRoutine.cs
  3. 17 0
      TModule.Downloader.asmdef
  4. 7 0
      TModule.Downloader.asmdef.meta

+ 2 - 1
DownloadManager.cs

@@ -1,11 +1,12 @@
1 1
 using System;
2 2
 using System.Collections;
3 3
 using System.Collections.Generic;
4
+using TFramework;
4 5
 using UnityEngine;
5 6
 
6 7
 namespace TModule.Runtime
7 8
 {
8
-    public class DownloadManager : MonoBehaviour
9
+    public class DownloadManager : BaseManager
9 10
     {
10 11
         private List<DownloadRoutine> _downloadRoutines = new List<DownloadRoutine>();
11 12
 

+ 9 - 1
DownloadRoutine.cs

@@ -87,6 +87,7 @@ namespace TModule.Runtime
87 87
             {
88 88
                 string info = webRequest.GetResponseHeader("Content-Length");
89 89
                 _totalSzie = long.Parse(info);
90
+                Debug.Log($"即将下载{url},下载大小{_totalSzie}");
90 91
                 await DownloadFile();
91 92
             }
92 93
         }
@@ -139,9 +140,16 @@ namespace TModule.Runtime
139 140
                                 onProgress?.Invoke((float)Math.Round((double)_currentDownloadSize / _totalSzie,2), _totalSzie, _currentDownloadSize);
140 141
                                 if (_currentDownloadSize >= _totalSzie)
141 142
                                 {
143
+                                    _currentDownloadSize = 0;
144
+                                    _totalSzie = 0;
145
+                                    DownLoadUrl = string.Empty;
146
+                                    FileSavePath = string.Empty;
147
+                                    onProgress = null;
148
+                                    onError = null;
149
+                                    onDownloadOver?.Invoke();
150
+                                    onDownloadOver = null;
142 151
                                     //下载完成
143 152
                                     IsLeisure = true;
144
-                                    onDownloadOver?.Invoke();
145 153
                                     break;
146 154
                                 }
147 155
                             }

+ 17 - 0
TModule.Downloader.asmdef

@@ -0,0 +1,17 @@
1
+{
2
+    "name": "TModule.Downloader",
3
+    "rootNamespace": "",
4
+    "references": [
5
+        "GUID:898501583428e8f489660e21e1ae83fe",
6
+        "GUID:f51ebe6a0ceec4240a699833d6309b23"
7
+    ],
8
+    "includePlatforms": [],
9
+    "excludePlatforms": [],
10
+    "allowUnsafeCode": false,
11
+    "overrideReferences": false,
12
+    "precompiledReferences": [],
13
+    "autoReferenced": true,
14
+    "defineConstraints": [],
15
+    "versionDefines": [],
16
+    "noEngineReferences": false
17
+}

+ 7 - 0
TModule.Downloader.asmdef.meta

@@ -0,0 +1,7 @@
1
+fileFormatVersion: 2
2
+guid: bdbd4945b56ace4478e1dfa9f119cbea
3
+AssemblyDefinitionImporter:
4
+  externalObjects: {}
5
+  userData: 
6
+  assetBundleName: 
7
+  assetBundleVariant: