Lyra-GameFeature
Lyra-GameFeature
Lyra-GameFeature
GameFeature_Action
ApplyFrontendPerfSettingsAction
(Source\LyraGame\UI\Frontend) 主要用于跟我们的游戏设置交互.开启和关闭前端性能限制的bool值
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/**
* GameFeatureAction responsible for telling the user settings to apply frontend/menu specific performance settings
* 游戏功能操作:负责向用户告知应应用前端/菜单特定的性能设置。
*/
UCLASS(MinimalAPI, meta = (DisplayName = "Use Frontend Perf Settings"))
class UApplyFrontendPerfSettingsAction final : public UGameFeatureAction
{
GENERATED_BODY()
public:
//~UGameFeatureAction interface
virtual void OnGameFeatureActivating(FGameFeatureActivatingContext& Context) override;
virtual void OnGameFeatureDeactivating(FGameFeatureDeactivatingContext& Context) override;
//~End of UGameFeatureAction interface
private:
static int32 ApplicationCounter;
};
1
2
ULyraSettingsLocal::Get()->SetShouldUseFrontendPerformanceSettings(true);
ULyraSettingsLocal::Get()->SetShouldUseFrontendPerformanceSettings(false);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
void ULyraSettingsLocal::SetShouldUseFrontendPerformanceSettings(bool bInFrontEnd)
{
bInFrontEndForPerformancePurposes = bInFrontEnd;
UpdateEffectiveFrameRateLimit();
}
void ULyraSettingsLocal::UpdateEffectiveFrameRateLimit()
{
// DS服务器不需要进行该项设置
if (!IsRunningDedicatedServer())
{
// 设置最大帧率
SetFrameRateLimitCVar(GetEffectiveFrameRateLimit());
}
}
float ULyraSettingsLocal::GetEffectiveFrameRateLimit()
{
const ULyraPlatformSpecificRenderingSettings* PlatformSettings = ULyraPlatformSpecificRenderingSettings::Get();
#if WITH_EDITOR
if (GIsEditor && !CVarApplyFrameRateSettingsInPIE.GetValueOnGameThread())
{
return Super::GetEffectiveFrameRateLimit();
}
#endif
if (PlatformSettings->FramePacingMode == ELyraFramePacingMode::ConsoleStyle)
{
return 0.0f;
}
float EffectiveFrameRateLimit = Super::GetEffectiveFrameRateLimit();
if (ShouldUseFrontendPerformanceSettings())
{
// 选择两者的最小值
EffectiveFrameRateLimit = CombineFrameRateLimits(EffectiveFrameRateLimit, FrameRateLimit_InMenu);
}
if (PlatformSettings->FramePacingMode == ELyraFramePacingMode::DesktopStyle)
{
// 是否使用电池
if (FPlatformMisc::IsRunningOnBattery())
{
EffectiveFrameRateLimit = CombineFrameRateLimits(EffectiveFrameRateLimit, FrameRateLimit_OnBattery);
}
// 是否是在后台
if (FSlateApplication::IsInitialized() && !FSlateApplication::Get().IsActive())
{
EffectiveFrameRateLimit = CombineFrameRateLimits(EffectiveFrameRateLimit, FrameRateLimit_WhenBackgrounded);
}
}
return EffectiveFrameRateLimit;
}
本文由作者按照 CC BY 4.0 进行授权