浏览代码

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

ks 6 年之前
父节点
当前提交
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()
 		{