Przeglądaj źródła

客户端提高获取hotfix types的性能

tanghai 7 lat temu
rodzic
commit
7e5bbcdde1
1 zmienionych plików z 6 dodań i 20 usunięć
  1. 6 20
      Unity/Assets/Model/Entity/Hotfix.cs

+ 6 - 20
Unity/Assets/Model/Entity/Hotfix.cs

@@ -16,16 +16,12 @@ namespace ETModel
 #endif
 
 		private IStaticMethod start;
+		private List<Type> hotfixTypes;
 
 		public Action Update;
 		public Action LateUpdate;
 		public Action OnApplicationQuit;
 
-		public Hotfix()
-		{
-
-		}
-
 		public void GotoHotfix()
 		{
 #if ILRuntime
@@ -36,23 +32,9 @@ namespace ETModel
 
 		public List<Type> GetHotfixTypes()
 		{
-#if ILRuntime
-			if (this.appDomain == null)
-			{
-				return new List<Type>();
-			}
-
-			return this.appDomain.LoadedTypes.Values.Select(x => x.ReflectionType).ToList();
-#else
-			if (this.assembly == null)
-			{
-				return new List<Type>();
-			}
-			return this.assembly.GetTypes().ToList();
-#endif
+			return this.hotfixTypes;
 		}
 
-
 		public void LoadHotfixAssembly()
 		{
 			Game.Scene.GetComponent<ResourcesComponent>().LoadBundle($"code.unity3d");
@@ -72,6 +54,8 @@ namespace ETModel
 			}
 
 			this.start = new ILStaticMethod(this.appDomain, "ETHotfix.Init", "Start", 0);
+			
+			this.hotfixTypes = this.appDomain.LoadedTypes.Values.Select(x => x.ReflectionType).ToList();
 #else
 			Log.Debug($"当前使用的是Mono模式");
 
@@ -79,6 +63,8 @@ namespace ETModel
 
 			Type hotfixInit = this.assembly.GetType("ETHotfix.Init");
 			this.start = new MonoStaticMethod(hotfixInit, "Start");
+			
+			this.hotfixTypes = this.assembly.GetTypes().ToList();
 #endif
 			
 			Game.Scene.GetComponent<ResourcesComponent>().UnloadBundle($"code.unity3d");