Просмотр исходного кода

修复BundleDownloadrComponent使用完后没有从Game.Scene中移除的bug (#149)

ks 6 лет назад
Родитель
Сommit
8dee8b8207
1 измененных файлов с 24 добавлено и 0 удалено
  1. 24 0
      Unity/Assets/Model/Module/AssetsBundle/BundleDownloaderComponent.cs

+ 24 - 0
Unity/Assets/Model/Module/AssetsBundle/BundleDownloaderComponent.cs

@@ -32,6 +32,30 @@ namespace ETModel
 		public string downloadingBundle;
 
 		public UnityWebRequestAsync webRequest;
+		
+		public override void Dispose()
+		{
+				if (this.IsDisposed)
+				{
+						return;
+				}
+
+				if (this.Entity.IsDisposed)
+				{
+						return;
+				}
+
+				base.Dispose();
+
+				this.remoteVersionConfig = null;
+				this.TotalSize = 0;
+				this.bundles = null;
+				this.downloadedBundles = null;
+				this.downloadingBundle = null;
+				this.webRequest?.Dispose();
+
+				this.Entity.RemoveComponent<BundleDownloaderComponent>();
+		}
 
 		public async ETTask StartAsync()
 		{