Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

游戏世界暂停后,coroutine delay 功能不工作 #276

Closed
xiejiangzhi opened this issue Oct 22, 2021 · 3 comments
Closed

游戏世界暂停后,coroutine delay 功能不工作 #276

xiejiangzhi opened this issue Oct 22, 2021 · 3 comments
Labels
pending release This will be released on next version

Comments

@xiejiangzhi
Copy link
Contributor

xiejiangzhi commented Oct 22, 2021

Unlua 1.2

通过蓝图创建 UI 后,使用蓝图节点 SetGamePause。

这时,游戏世界是暂停的,UI是可以正常使用的。

在 widget 蓝图中, construct 后或者任何事件后,都可以正常加入 delay 节点,并能执行节点后的逻辑。

而在 lua 中通过 coroutine 调用的 delay ,在游戏暂停时,永远不会被执行,只会等到游戏取消暂停后才会继续执行。

lua 调用 delay 传入的 world context object 是 widget 本身。

源代码看不懂 latent 的实现。求助!

@xiejiangzhi xiejiangzhi changed the title 游戏世界暂停后,coroutinue delay 功能不工作 游戏世界暂停后,coroutine delay 功能不工作 Oct 22, 2021
@xiejiangzhi
Copy link
Contributor Author

xiejiangzhi commented Oct 25, 2021

刚看了下源码,蓝图的 Delay CallbackTarget 应该就是当前对象本身, widget 里面就是绑定了当前 widget

LatentActionManager.AddNewAction(LatentInfo.CallbackTarget, LatentInfo.UUID, new FDelayAction(Duration, LatentInfo))

发现 UnLua 里面 Latent 绑定是的 UnluaManager,。

而 FLatentActionManager::ProcessLatentActions 在被 widget 调用处理 Latent Actions 时,会按 CallbackTarget 对象过滤,也就是只触发当前 widget 的。只有在 LevelTick 时,ProcessLatentActions 调用是传入 nullprt ,然后就不会过滤对象,然后才会处理所有没有被处理的 Latent 回调,包括 UnLua 的。。。。。

@xuyanghuang-tencent
Copy link
Collaborator

的确有这个问题,因为一些历史设计原因目前没有找到更优雅的设计,可以参考上面的两个提交:

https://github.com/Tencent/UnLua/blob/feature/tests/Content/Script/Tests/Regression/Issue276/TestWidget.lua

增加了UUnLuaLatentAction:SetTickableWhenPaused()用来应对需要Pause和非Pause的应用场景,下个版本会合入master

@xiejiangzhi
Copy link
Contributor Author

辛苦辛苦,, 由于不太了解 C++ 方面的东西,我自己就简单弄了一个暂停游戏后可以手动 Tick 的 TimerManager 来解决延迟时的问题。。。

@xuyanghuang-tencent xuyanghuang-tencent added the pending release This will be released on next version label Nov 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending release This will be released on next version
Projects
None yet
Development

No branches or pull requests

2 participants