提交 7e5bbcdd 编写于 作者: T tanghai

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

上级 22a86995
...@@ -16,16 +16,12 @@ namespace ETModel ...@@ -16,16 +16,12 @@ namespace ETModel
#endif #endif
private IStaticMethod start; private IStaticMethod start;
private List<Type> hotfixTypes;
public Action Update; public Action Update;
public Action LateUpdate; public Action LateUpdate;
public Action OnApplicationQuit; public Action OnApplicationQuit;
public Hotfix()
{
}
public void GotoHotfix() public void GotoHotfix()
{ {
#if ILRuntime #if ILRuntime
...@@ -36,23 +32,9 @@ namespace ETModel ...@@ -36,23 +32,9 @@ namespace ETModel
public List<Type> GetHotfixTypes() public List<Type> GetHotfixTypes()
{ {
#if ILRuntime return this.hotfixTypes;
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
}
public void LoadHotfixAssembly() public void LoadHotfixAssembly()
{ {
Game.Scene.GetComponent<ResourcesComponent>().LoadBundle($"code.unity3d"); Game.Scene.GetComponent<ResourcesComponent>().LoadBundle($"code.unity3d");
...@@ -72,6 +54,8 @@ namespace ETModel ...@@ -72,6 +54,8 @@ namespace ETModel
} }
this.start = new ILStaticMethod(this.appDomain, "ETHotfix.Init", "Start", 0); this.start = new ILStaticMethod(this.appDomain, "ETHotfix.Init", "Start", 0);
this.hotfixTypes = this.appDomain.LoadedTypes.Values.Select(x => x.ReflectionType).ToList();
#else #else
Log.Debug($"当前使用的是Mono模式"); Log.Debug($"当前使用的是Mono模式");
...@@ -79,6 +63,8 @@ namespace ETModel ...@@ -79,6 +63,8 @@ namespace ETModel
Type hotfixInit = this.assembly.GetType("ETHotfix.Init"); Type hotfixInit = this.assembly.GetType("ETHotfix.Init");
this.start = new MonoStaticMethod(hotfixInit, "Start"); this.start = new MonoStaticMethod(hotfixInit, "Start");
this.hotfixTypes = this.assembly.GetTypes().ToList();
#endif #endif
Game.Scene.GetComponent<ResourcesComponent>().UnloadBundle($"code.unity3d"); Game.Scene.GetComponent<ResourcesComponent>().UnloadBundle($"code.unity3d");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册