Tencent / UnLua

A feature-rich, easy-learning and highly optimized Lua scripting plugin for UE.
Other
2.24k stars 614 forks source link

lua重写ReceiveBeginPlay,加上蓝图调用【父类:ReceiveBeginPlay】的时候,会出问题 #722

Open shuitian opened 2 months ago

shuitian commented 2 months ago

测试环境: 蓝图类

  1. DebugBattleBug 只连了ReceiveBeginPlay image 父类实现了unlua插件 image

  2. DebugBattleBug_Child 是DebugBattleBug的子类,蓝图里调用了父类的ReceiveBeginPlay image

  3. lua代码中,实现了ReceiveBeginPlay image

  4. 在测试场景中拖入两个DebugActor image

  5. 开始运行,会出问题

由于这里调用父类的ReceiveBeginPlay,实际上会调用到lua中去,又会调用到子类蓝图中,疑似出现死循环?

HuaNanHYC commented 2 months ago

对的,因为编辑器在运行时检测到UObject才会绑定Lua文件; 如果世界中只有Child,那么父类的ReceiveBeginPlay就只是一个打印字符串,Child中调用的父类函数只是打印字符串; 但是父类也放到世界中运行时就会绑定,父类的ReceiveBeginPlay就变成了self.Overridden.ReceiveBeginPlay(self),那在Child的ReceiveBeginPlay中调用的就是self.Overridden.ReceiveBeginPlay(self),会形成死循环。

BaconVN commented 1 month ago

Cherry pick this PR. This should solve the problem.

https://github.com/Tencent/UnLua/pull/719