调用/执行 热更中的方法#
调用热更代码中方法,写在AppDomain中,记录一下主要几个方法:
AppDomain.LoadAssembly 加载热更dll
执行热更代码的方法,有两种方式:
- appdomain.Invoke(“HotFix_Project.InstanceClass”, “StaticFunTest”, null, null);
- 预先获得IMethod,可以减低每次调用查找方法耗用的时间,代码如下:
//预先获得IMethod,可以减低每次调用查找方法耗用的时间
IType type = appdomain.LoadedTypes["HotFix_Project.InstanceClass"];
//根据方法名称和参数个数获取方法
IMethod method = type.GetMethod("StaticFunTest", 0);
appdomain.Invoke(method, null, null);
监听主工程的委托#
在热更工程中监听主工