【发布时间】:2020-05-09 11:11:15
【问题描述】:
我正在循环一个 http 请求并调用一个请求 json 指令的 url。 我必须循环才能知道游戏接下来应该做的事情。如果我打包游戏,它工作顺利。但在开发和按下播放时,游戏确实继续,但视口上的输出就像 10 fps,除非我单击游戏窗口。如果您的键盘或鼠标聚焦在另一个窗口而不是编辑器上,则视口面板似乎是故意这样做的。
Request = FHttpModule::Get().CreateRequest();
Request->OnProcessRequestComplete().BindUObject(this, &ABoxGridActor::OnResponseReceived);
// //This is the url on which to process the request
Request->SetURL("http://localhost:8092");
Request->SetVerb("GET");
Request->SetHeader(TEXT("User-Agent"), "X-UnrealEngine-Agent");
Request->SetHeader("Content-Type", TEXT("application/json"));
//Request->ProcessRequest();
////not timer loop, one time only
GetWorldTimerManager().SetTimer(tmr, this, &ABoxGridActor::RepeatingFunction, 0.2f, true);
void ABoxGridActor::RepeatingFunction()
{
if (!boolHasPassed)
{
boolHasPassed = true;
Request->ProcessRequest();
return;
}
}
void ABoxGridActor::OnResponseReceived(FHttpRequestPtr RequestP, FHttpResponsePtr Response, bool bWasSuccessful)
{
boolHasPassed = false;
//codes
}
【问题讨论】:
-
焦点问题或低 fps 与您的 http 循环有何关系?
标签: unreal-engine4