Hi, how to make the game reduce the activity to 1 fps when minimizing the window, as it does unreal engine editor?
You can try to use the bUseFixedFrameRate from the GEngine
What I did for a launcher, I detect when the window is minimized.
bool SKMainContentWidget::CheckWindowMinimized(float InDeltaTime)
{
if (GEngine && GEngine->GameViewport)
{
bool bReduceTick = (IsGameRunning() || GEngine->GameViewport->GetWindow()->IsWindowMinimized());
if (bReduceTick && GEngine->bUseFixedFrameRate == false)
{
GEngine->bUseFixedFrameRate = true;
GEngine->FixedFrameRate = 5.f;
}
else
if (bReduceTick == false && GEngine->bUseFixedFrameRate)
{
GEngine->bUseFixedFrameRate = false;
GEngine->FixedFrameRate = 30.f;
}
}
return true;
}
In the Construct of the main widget, I check every second for the window if minimized.
void SKMainContentWidget::Construct(const FArguments& InArgs)
{
UE_LOG(LogKSGMDebug, Verbose, TEXT("SKMainContentWidget::Construct"));
SKContentMenuWidget::Construct(SKContentMenuWidget::FArguments().PlayerOwner(InArgs._PlayerOwner));
// Not logged in at startup
IsLoggedIn = false;
// Create a ticker that will check if the windows is minimized and the game is running
// to adapt the tick update to reduce the slate GPU consumption
CheckWindowTickHandle = FTSTicker::GetCoreTicker().AddTicker(FTickerDelegate::CreateSP(this, &SKMainContentWidget::CheckWindowMinimized), 1.0f);
}
2 Likes
If you have access to the engine source code you can have a look at EditorEngine.cpp in UEditorEngine::GetMaxTickRate where this feature is implemented for the editor and add something similar to GameEngine.cpp in UGameEngine::GetMaxTickRate
2 Likes