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

JBehaviour Loop Failed #511

Open
manbaaa opened this issue Jun 11, 2024 · 1 comment
Open

JBehaviour Loop Failed #511

manbaaa opened this issue Jun 11, 2024 · 1 comment

Comments

@manbaaa
Copy link

manbaaa commented Jun 11, 2024

在热更方法 RunGame 里动态创建JBehaviour,最开始创建的前几个的Loop方法不会执行。

需要打包环境测试,在JBehaviour.cs里屏蔽掉如下代码:

//编辑器下可视化
if (Application.isEditor)
{
var id = AddClassBind(gameObject, activeAfter, typeof(T));
var ret = (T)JBehaviours[id];
ret.Check();
return ret;
}

可以在Unity编辑器下重现,前提是FpsMonitor里的_backupFrames初始化为0;

@manbaaa
Copy link
Author

manbaaa commented Jun 11, 2024

public JBehaviour Activate()
{
//主线程
ThreadMgr.QueueOnMainThread(() =>
{
Awake();
var duration = 1f / ((float)Application.targetFrameRate <= 0
? FpsMonitor.FPS
: Application.targetFrameRate);
duration = duration / TimeScale;
ThreadMgr.QueueOnMainThread(() =>
{
OnEnable();
Start();
}, duration);
});
return this;
}

测试下来是因为在 JBehaviour 执行 Activate是 FpsMonitor.FPS值为0,导致duration值很大。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant