BDFramework 热更调用AddComponent

众所周知,BDF代码热更使用的是ILRuntime,燃鹅ILR中使用AddComponent需要先搞一个MonoBehavior的Adaptor,然后再CLR重定向劫持一下AddComponent才可以。
虽然很麻烦但是BDF作者已经帮我们搞定了,Adaptor已经有了,CLR重定向在编译hotfix.dll的时候会自动生成。

MonoAdaptor在
Assets/Code/Game/ILRuntime/Adapter/Manual/MonoBehaviourAdapter.cs
AddComponent在
Assets/Code/Game/ILRuntime/Binding/Analysis/UnityEngine_GameObject_Binding.cs
如果没有AddComponent相关的CLR重定向代码,需要在热更中调用一下Addcomponent然后编译一下hotfix.dll就有了。

如果调用AddComponent报空引用,需要把config中的code mode改成反射模型,ILR模式会报空引用。

尽量不要在热更中调用mono,因为泡哥说:

全局除了UI组件之外,不允许任何脚本继承MonoBehavior.

你可能感兴趣的:(BDFramework 热更调用AddComponent)