Keywords: UE4, Console, Command

Editor命令

ShowFlag

如果想在 Editor 中查看 Actor 蓝图的 Bounds(默认只能在 Static Mesh 编辑窗口中查看),可以使用 ShowFlag 命令(在编辑器窗口中按下波浪键打开输入窗口)。

开启:

ShowFlag.Bounds 1

关闭:

ShowFlag.Bounds 0

凡是 Show 命令能查看的参数,ShowFlag也能查看,包括Collision等。

如果想在游戏运行时查看指定物体的 Bounds,那么可以先执行 ShowFlag.Bounds 1,然后再以 Simulate 模式运行游戏,然后再在场景中单击要查看的物体,然后就可以显示该物体的 Bounds 信息。

运行时命令

Camera

修改Camera Mode(切换摄像机视角): Camera [modename] 其中modename的值为:

static const FName NAME_Fixed = FName(TEXT("Fixed"));
static const FName NAME_ThirdPerson = FName(TEXT("ThirdPerson"));
static const FName NAME_FreeCam = FName(TEXT("FreeCam"));
static const FName NAME_FreeCam_Default = FName(TEXT("FreeCam_Default"));
static const FName NAME_FirstPerson = FName(TEXT("FirstPerson"));

启用debug camera:

ToggleDebugCamera
Rendering

渲染优化分析视图模式:

//Lit view mode shows the final result of your scene once all of the Materials and lighting have been applied.
//Hotkey: Alt + 4
viewmode lit

//Unlit view mode removes all lighting from the scene, showing you Base Color only.
//Hotkey: Alt + 3
viewmode unlit

//Wireframe shows all of the polygon edges in the scene. In the case of Brushes, you will see the resultant geometry. 
//Hotkey: Alt + 2
viewmode wireframe

//Detail Lighting activates a neutral Material across the entire scene, using the normal maps of the original materials. This is useful for isolating whether your BaseColor is obscuring lighting by being too dark or noisy. 
//Hotkey: Alt + 5
viewmode lit_detaillighting

//Lighting Only shows a neutral Material that is only affected by lighting. It differs from Detail Lighting mode in that you will not see normal maps. 
//Hotkey: Alt + 6
viewmode lightingonly

//Light Complexity shows the number of non-static lights affecting your geometry. This is useful for tracking lighting cost - the more lights affecting a surface, the more expensive it will be to shade. 
//Hotkey: Alt + 7
viewmode lightcomplexity

//Shader Complexity Mode is used to visualize the number of shader instructions being used to calculate each pixel of your scene. It is generally a good indication of how performance-friendly your scene will be. In general, it is used to test overall performance for your base scene, as well as to optimize particle effects, which tend to cause performance spikes with a large amount of overdraw for a short period of time. 
//Hotkey: Alt + 8
viewmode shadercomplexity

//view quad overdraw
viewmode quadoverdraw

参考:View Modes
https://docs.unrealengine.com/4.26/en-US/BuildingWorlds/LevelEditor/Viewports/ViewModes/

显示 Buffer Visualization
先执行(若要退出Buffer Visualization,执行:ViewMode Lit):

//打开所有Buffer Visualization参数的矩阵视图
ViewMode VisualizeBuffer

再切换到单个参数视图,比如,想查看AO(若要退出当前视图,执行:r.BufferVisualizationTarget ""):

r.BufferVisualizationTarget AmbientOcclusion

其中,r.BufferVisualizationTarget的可选参数包括:BaseColor CustomDepth CustomStencil FinalImage ShadingModel MaterialAO Metallic Opacity Roughness SceneColor SceneDepth SeparateTranslucencyRGB SeparateTranslucencyA Specular SubsurfaceColor WorldNormal AmbientOcclusion CustomDepthWorldUnits SceneDepthWorldUnits PreTonemapHDRColor PostTonemapHDRColor等。

ViewModer.BufferVisualizationTarget的参数,也就是Viewport左上角View ModeBuffer Visualization Mode下的菜单名:

参考:Console commands for Buffer Visualization
https://answers.unrealengine.com/questions/139442/console-commands-for-buffer-visualization.html

显示刚体

Show Collision

显示帧率

stat fps

显示mesh drawcall

stat scenerendering

显示UMG Widget drawcall

stat slate

显示static mesh、skeletal mesh的三角面数量

stat Engine

显示硬件级(RHI)三角面总数和drawcall总数

stat rhi

其中:

  • Triangles drawn是最终绘制的面数,即camera frustum和occlusion culling之后的面数。数量包含了shadow和tessellation,所以数值会显著高于stat Engine中的三角面数;
  • DrawPrimitive calls数量除了geometry,还包括decals、shadows、translucent lighting volumes、post processing等,其数值也会明显高于stat scenerendering中的draw call数。

显示单帧信息:总时长、Game耗时、Draw耗时、GPU耗时

stat Unit
stat UnitGraph  //附带各个参数的实时曲线图

显示当前帧的CPU时间信息(各种Tick, GC Mark,Update Overlaps等):

stat game

设置渲染分辨率为默认大小的50%(500就表示实际viewport大小的5倍尺寸来渲染,可以用来做压力测试,判断性能瓶颈是不是像素处理)

r.ScreenPercentage 50

r.SetRes也可以判断瓶颈是否和像素相关。和r.ScreenPercentage功能相同,但r.ScreenPercentage有额外开销。

r.SetRes 1920x1080f

查看遮挡剔除:

r.visualizeOccludedPrimitives 1

启用early Z pass,默认已开启:

r.EarlyZPass 3

较高的drawcall情况下,开启后如果basepass的overdraw反而较少,说明early Z pass效果明显。修改值后需要重新运行游戏生效。

关闭或开启屏幕上打印信息(AddOnScreenDebugMessage)

DisableAllScreenMessages

EnableAllScreenMessages

Viewport高清截图

//以当前viewport分辨率的两倍进行截图
HighResShot 2

//指定分辨率截图
HighResShot 3840x2160

图片存储位置:\Saved\Screenshots\

Taking Screenshots
https://docs.unrealengine.com/en-US/Engine/Basics/Screenshots/index.html

Dump Console Commands

Q:console的命令非常多,如何将所有命令全部dump出一个列表?
A:使用命令dumpconsolecommands,执行后,所有可用的命令会存储在\Saved\Logs\下的log文件中。

参考自:Where can I find all the console commands?
https://answers.unrealengine.com/questions/255772/where-can-i-find-all-the-console-commands.html

或者直接查看引擎源码:
Engine\Source\Runtime\Engine\Private\UnrealEngine.cpp

bool UEngine::Exec( UWorld* InWorld, const TCHAR* Cmd, FOutputDevice& Ar )
性能统计图工具 Session Frontend

用于记录某段时间内的性能分析数据。

在需要开始统计的时刻执行:

stat startfile

在统计完成的时刻执行:

stat stopfile

此时会在路径 Saved/Profiling/UnrealStats 下生成数据文件。
然后点击:Windows -》 Developer Tools -》 Session Frontend -》点击 Profiler 选项卡 -》 点击 Load 按钮,载入前面生成的数据文件。

性能统计自身也会消耗一定性能,有没办法将性能统计的自身消耗,从性能统计的计算结果中排除掉?答案是:No!至少目前版本不支持。

Profiling & Debugging

CPU

CPU性能问题(耗时高、卡顿等)大多出现在GameThread、RenderThread上。

记录卡顿时间(通过t.HitchFrameTimeThreshold(单位ms,默认60。旧版本叫t.HitchThreshold)定义卡顿时长阀值)

stat Hitches    //或者stat DumpHitches 记录log文件

程序运行时一旦某帧耗时超过t.HitchFrameTimeThreshold指定的时长,则函数堆栈就会被打印出来。
例如,以下 hitchdump 显示LoadObject耗时较长(Self表示函数堆栈中上一级函数,即LoadObject,所占用耗时),则表示是加载资源导致顿卡

   477.514ms (   4)  -  Thread_4118_0 - GameThread - STATGROUP_Threads - STATCAT_Advanced
     477.510ms (   2)  -  FrameTime - STAT_FrameTime - STATGROUP_Engine - STATCAT_Advanced
       470.844ms (   1)  -  FrameTime - STAT_FrameTime - STATGROUP_Engine - STATCAT_Advanced
         470.840ms (   1)  -  World Tick Time - STAT_WorldTickTime - STATGROUP_Game - STATCAT_Advanced
           470.758ms (   5)  -  Tick Time - STAT_TickTime - STATGROUP_Game - STATCAT_Advanced
             470.590ms (   2)  -  TG_PrePhysics - STAT_TG_PrePhysics - STATGROUP_TickGroups - STATCAT_Advanced
               470.585ms (   2)  -  ReleaseTickGroup Block - STAT_ReleaseTickGroup_Block - STATGROUP_TickGroups - STATCAT_Advanced
                 470.579ms (   1)  -  Game TaskGraph Tasks - STAT_TaskGraph_GameTasks - STATGROUP_Threading - STATCAT_Advanced
                   470.512ms (  20)  -  FTickFunctionTask - STATGROUP_TaskGraphTasks - STATCAT_Advanced
                     470.309ms (   1)  -  BaseGameMode/Game/Map/PVP/UEDPIE_0_PVP.PVP.PersistentLevel.BaseGameMode - STATGROUP_UObjects - STATCAT_Advanced
                       469.638ms (   3)  -  LoadObject - STAT_LoadObject - STATGROUP_Object - STATCAT_Advanced
                         377.887ms (   3)  -  Self
                         26.688ms ( 533)  -  STAT_FArchiveAsync2_WaitRead - STATGROUP_Quick - STATCAT_Advanced

stat DumpHitches命令有可选参数,-start-stop,表示dump的开始和结束位置:

stat DumpHitches -start
stat DumpHitches -stop

默认只会打印GameThread、RenderThread上的卡顿,如果希望打印其他线程卡顿,比如AudioThread、TaskGraph等,执行命令:t.DumpHitches.AllThreads 1

渲染相关的CPU性能问题还可以通过 stat scenerenderingstat game 等命令分析,如果某类型的 draw call 数量特别高,说明这是 CPU 的瓶颈所在。

CPU Profiling
https://docs.unrealengine.com/en-us/Engine/Performance/CPU

GPU

在编辑器中运行游戏时,按下 Ctrl + Shift + 逗号,或者命令行输入:profilegpu ,打开 GPUProfile 面板,显示当前帧的各类计算的耗时:PostProcess、Lighting 等。
注意:是当前一帧的耗时,不是平均每帧的耗时。

另外一个类似命令:profilegpuhitches,表示每当GPU有卡顿时,自动弹出一个当时所在帧的 GPUProfile 面板。

GPUProfile面板上的可视化信息,在log文件(工程名\Saved\Logs\工程名.log)里面也会以文本形式打印出来。
在Development 打包模式下,由于无法打开GPUProfile 面板,所以分析数据只打印在log里,例如:

Profiling the next GPU frame
LogD3D11RHI: Warning: 
LogD3D11RHI: Warning: 
LogRHI: Perf marker hierarchy, total GPU time 4.33ms
LogRHI: Warning: Profiled range was continuous.
LogRHI: 100.0% 4.33ms   FRAME 635 draws 16087 prims 18018 verts
LogRHI: 97.1% 4.20ms   Scene 633 draws 15751 prims 17346 verts
LogRHI:     1.1% 0.05ms   PrePass DDM_AllOpaque (Forced by DBuffer) 141 draws 5744 prims 5634 verts
LogRHI:        0.3% 0.01ms   BeginRenderingPrePass 1 draws 0 prims 0 verts
LogRHI:     0.5% 0.02ms   ComputeLightGrid 5 draws 5 prims 0 verts
LogRHI:        0.3% 0.01ms   CullLights 30x17x32 NumLights 0 NumCaptures 1 4 draws 4 prims 0 verts
LogRHI:        0.2% 0.01ms   Compact 1 draws 1 prims 0 verts
LogRHI:     0.1% 0.00ms   BeginOcclusionTests 16 draws 192 prims 128 verts
LogRHI:        0.1% 0.00ms   ViewOcclusionTests 0 16 draws 192 prims 128 verts
LogRHI:           0.1% 0.00ms   IndividualQueries 16 draws 192 prims 128 verts

如果不需要gpu耗时存到文本,也不需要GUI面板,只是在屏幕上实时打印,使用命令:

stat gpu

如果是在编辑器模式,建议以“新窗口”(New Editor Window)PIE模式运行,如果是在编辑器的Viewport中运行,会把编辑器的消耗也算进去(即使是全屏模式)。

GPU Profiling
https://docs.unrealengine.com/en-us/Engine/Performance/GPU

Memory

内存相关的优化调试命令:

//这些命令定义在 Engine\Config\BaseEngine.ini 中
[MemReportCommands]
; These commands are run when memreport is executed, and output to a profile file
+Cmd="Mem FromReport"
+Cmd="LogCountedInstances"
+Cmd="obj list -alphasort"
+Cmd="rhi.DumpMemory"
+Cmd="LogOutStatLevels"
+Cmd="ListSpawnedActors"

[MemReportFullCommands]
; Additional commands to run with memreport -full
+Cmd="DumpParticleMem"
+Cmd="ConfigMem"
+Cmd="r.DumpRenderTargetPoolMemory"
+Cmd="ListTextures"
+Cmd="ListSounds -alphasort"
+Cmd="ListParticleSystems -alphasort"
+Cmd="obj list class=SoundWave -alphasort"
+Cmd="obj list class=SkeletalMesh -alphasort"
+Cmd="obj list class=StaticMesh -alphasort"
+Cmd="obj list class=Level -alphasort"
+Cmd="obj list class=StaticMeshComponent -alphasort"

处理obj list命令的代码位置:
Engine\Source\Runtime\Engine\Private\UnrealEngine.cpp

else if( FParse::Command(&Cmd,TEXT("LIST")) )

Low-Level Memory Tracker. Going over how to use the Low-Level Memory Tracker in your Unreal Engine projects.
https://docs.unrealengine.com/4.27/en-US/ProductionPipelines/DevelopmentSetup/Tools/LowLevelMemoryTracker/

Debugging and Optimizing Memory
https://www.unrealengine.com/en-US/blog/debugging-and-optimizing-memory

Crash Testing

Force game crash (not available in shipping):

debug threadcrash

Misc

工程设置相关

使用stat相关命令检测性能时,需要关闭Smooth Frame Rate来保证检测结果更精准:
Project Settings -> Engine -> General Settings -> Framerate -> Uncheck Smooth Frame Rate

运行时期间用C++执行console命名
UKismetSystemLibrary::ExecuteConsoleCommand(UObject* WorldContextObject, 
    const FString& Command, class APlayerController* SpecificPlayer = NULL )
运行时期间修改画质级别

Unreal Engine 4 Save and Load Graphics Settings using Blueprints Tutorial
https://www.youtube.com/watch?v=5AXA2CrPwTo

Change Graphics Settings In-Game - Unreal Engine 4 Tutorial
https://www.youtube.com/watch?v=T90vqA9x5so

Command:

r.PostProcessAAQuality 0
sg.PostProcessQuality 0
sg.ShadowQuality 0
sg.TextureQuality 0
sg.EffectsQuality 0
r.DetailMode 0
foliage.DensityScale 0.25
grass.DensityScale 0.25

Scalability Reference
https://docs.unrealengine.com/en-us/Engine/Performance/Scalability/ScalabilityReference

蓝图Execute Console Command节点(C++接口:UKismetSystemLibrary::ExecuteConsoleCommand())在 Shipping 模式下仍然有效。

移动端修改画质级别(安卓为例):

\Engine\Config\Android\AndroidScalability.ini

不同设备的默认配置(\Engine\Config\BaseDeviceProfiles.ini),以高端安卓机为例:

[Android_High DeviceProfile]
DeviceType=Android
BaseProfileName=Android
+CVars=sg.ViewDistanceQuality=2
+CVars=sg.AntiAliasingQuality=2
+CVars=sg.ShadowQuality=2
+CVars=sg.PostProcessQuality=2
+CVars=sg.TextureQuality=2
+CVars=sg.EffectsQuality=2
+CVars=sg.FoliageQuality=2
+CVars=r.MobileContentScaleFactor=1.0

程序启动时自动设置画质级别的位置:
Engine\Source\Runtime\Engine\Private\DeviceProfiles\DeviceProfileManager.cpp

/**
 * Startup and select the active device profile
 * Then Init the CVars from this profile and it's Device profile parent tree.
 */
static void InitializeCVarsForActiveDeviceProfile(bool bPushSettings=false, bool bForceDeviceProfilePriority = false);

手动检测硬件配置详情并自动设置画质级别:
console命令

//此命令同时会将硬件性能信息打印到文本log
scalability auto

C++ API

if(UGameUserSettings* GameUserSettings = UGameUserSettings::GetGameUserSettings())
{
    GameUserSettings->RunHardwareBenchmark();
    GameUserSettings->ApplyHardwareBenchmarkResults();
}

获取硬件(CPU、GPU)跑分:

const Scalability::FQualityLevels State = Scalability::BenchmarkQualityLevels();
const float CPUIndex = State.CPUBenchmarkResults;
const float GPUIndex = State.GPUBenchmarkResults;

返回值对应Engine\Config\BaseScalability.ini中的配置:

[ScalabilitySettings]
; PerfIndexThresholds define the thresholds that determine what the autodetected quality should be for each group.
; When you auto detect performance, both a CPUIndex and GPUIndex are calculated on the machine.
; Use the console command "scalability auto" to print these values for a machine.
; The type of perfindex used to determine the quality for a group is either the GPU, CPU or Min.
; GPU means the quality is based on the speed of the graphics card. CPU means the quality is based on the processor, and Min means the group quality is based on the slower of either the CPU or GPU.
; Each group has a type followed by three numbers.
; The first number is the perfindex threshold that changes quality from 0 to 1. The second is the threshold from 1 to 2, the third is the threshold from 2 to 3.
PerfIndexThresholds_ResolutionQuality="GPU 18 42 115"
PerfIndexThresholds_ViewDistanceQuality="Min 18 42 105"
PerfIndexThresholds_AntiAliasingQuality="GPU 18 42 115"
PerfIndexThresholds_ShadowQuality="Min 18 42 105"
PerfIndexThresholds_PostProcessQuality="GPU 18 42 115"
PerfIndexThresholds_TextureQuality="GPU 18 42 115"
PerfIndexThresholds_EffectsQuality="Min 18 42 105"
PerfIndexThresholds_FoliageQuality="GPU 18 42 115"
PerfIndexThresholds_ShadingQuality="GPU 18 42 115"

; This is the screen percentage for the resolution quality, corresponding to 25% pixels, 50% pixels, 75% pixels, and 100% pixels
PerfIndexValues_ResolutionQuality="50 71 87 100 100"

输出的文本信息:

Cmd: scalability auto
LogSynthBenchmark: Display: FSynthBenchmark (V0.95):  requested WorkScale=10.00
LogSynthBenchmark: Display: ===============
LogSynthBenchmark: Display: Main Processor:
LogSynthBenchmark: Display:          ... 0.049066 s/Run 'RayIntersect'
LogSynthBenchmark: Display:          ... 0.030856 s/Run 'Fractal'
LogSynthBenchmark: Display: 
LogSynthBenchmark: Display:   CompiledTarget_x_Bits: 64
LogSynthBenchmark: Display:   UE_BUILD_SHIPPING: 0
LogSynthBenchmark: Display:   UE_BUILD_TEST: 0
LogSynthBenchmark: Display:   UE_BUILD_DEBUG: 0
LogSynthBenchmark: Display:   TotalPhysicalGBRam: 32
LogSynthBenchmark: Display:   NumberOfCores (physical): 8
LogSynthBenchmark: Display:   NumberOfCores (logical): 8
LogSynthBenchmark: Display:   CPU Perf Index 0: 52.2 (weight 1.00)
LogSynthBenchmark: Display:   CPU Perf Index 1: 92.7 (weight 1.50)
LogSynthBenchmark: Display:  
LogSynthBenchmark: Display: Graphics:
LogSynthBenchmark: Display:   Adapter Name: 'Radeon RX 470 Series'
LogSynthBenchmark: Display:   (On Optimus the name might be wrong, memory should be ok)
LogSynthBenchmark: Display:   Vendor Id: 0x1002
LogSynthBenchmark: Display:   Device Id: 0x67DF
LogSynthBenchmark: Display:   Device Revision: 0xFF
LogSynthBenchmark: Display:   GPU Memory: 4076/0/16351 MB
LogSynthBenchmark: Display:   GPU first test: 0.05s
LogSynthBenchmark: Display:          ... 7.508 s/GigaPix, Confidence=89% 'ALUHeavyNoise' (likely to be very inaccurate)
LogSynthBenchmark: Display:          ... 5.685 s/GigaPix, Confidence=89% 'TexHeavy' (likely to be very inaccurate)
LogSynthBenchmark: Display:          ... 5.209 s/GigaPix, Confidence=89% 'DepTexHeavy' (likely to be very inaccurate)
LogSynthBenchmark: Display:          ... 15.020 s/GigaPix, Confidence=40% 'FillOnly' (likely to be very inaccurate)
LogSynthBenchmark: Display:          ... 0.629 s/GigaPix, Confidence=100% 'Bandwidth' (likely to be very inaccurate)
LogSynthBenchmark: Display:          ... 2.354 s/GigaVert, Confidence=51% 'VertThroughPut1' (likely to be very inaccurate)
LogSynthBenchmark: Display:          ... 4.441 s/GigaVert, Confidence=100% 'VertThroughPut2' (likely to be very inaccurate)
LogSynthBenchmark: Display:   GPU second test: 0.29s
LogSynthBenchmark: Display:          ... 11.496 s/GigaPix, Confidence=70% 'ALUHeavyNoise' (likely to be inaccurate)
LogSynthBenchmark: Display:          ... 8.107 s/GigaPix, Confidence=89% 'TexHeavy' (likely to be inaccurate)
LogSynthBenchmark: Display:          ... 7.910 s/GigaPix, Confidence=100% 'DepTexHeavy' (likely to be inaccurate)
LogSynthBenchmark: Display:          ... 32.663 s/GigaPix, Confidence=100% 'FillOnly' (likely to be inaccurate)
LogSynthBenchmark: Display:          ... 0.672 s/GigaPix, Confidence=100% 'Bandwidth' (likely to be inaccurate)
LogSynthBenchmark: Display:          ... 2.340 s/GigaVert, Confidence=100% 'VertThroughPut1' (likely to be inaccurate)
LogSynthBenchmark: Display:          ... 4.447 s/GigaVert, Confidence=100% 'VertThroughPut2' (likely to be inaccurate)
LogSynthBenchmark: Display:   GPU Final Results:
LogSynthBenchmark: Display:          ... 11.496 s/GigaPix, Confidence=70% 'ALUHeavyNoise'
LogSynthBenchmark: Display:          ... 8.107 s/GigaPix, Confidence=89% 'TexHeavy'
LogSynthBenchmark: Display:          ... 7.910 s/GigaPix, Confidence=100% 'DepTexHeavy'
LogSynthBenchmark: Display:          ... 32.663 s/GigaPix, Confidence=100% 'FillOnly'
LogSynthBenchmark: Display:          ... 0.672 s/GigaPix, Confidence=100% 'Bandwidth'
LogSynthBenchmark: Display:          ... 2.340 s/GigaVert, Confidence=100% 'VertThroughPut1'
LogSynthBenchmark: Display:          ... 4.447 s/GigaVert, Confidence=100% 'VertThroughPut2'
LogSynthBenchmark: Display: 
LogSynthBenchmark: Display:   GPU Perf Index 0: 249.9 (weight 1.00)
LogSynthBenchmark: Display:   GPU Perf Index 1: 108.9 (weight 0.10)
LogSynthBenchmark: Display:   GPU Perf Index 2: 205.6 (weight 0.10)
LogSynthBenchmark: Display:   GPU Perf Index 3: 128.3 (weight 3.00)
LogSynthBenchmark: Display:   GPU Perf Index 4: 62.7 (weight 1.00)
LogSynthBenchmark: Display:   GPU Perf Index 5: 152.2 (weight 0.00)
LogSynthBenchmark: Display:   GPU Perf Index 6: 251.7 (weight 0.00)
LogSynthBenchmark: Display:   GPUIndex: 140.2
LogSynthBenchmark: Display:   CPUIndex: 76.5
LogSynthBenchmark: Display: 
LogSynthBenchmark: Display:          ... Total Time: 2.228119 sec

Auto-detect Optimal Graphics Settings for Unreal
https://www.tomlooman.com/auto-detect-graphics-settings-ue4/

GameUserSettings->RunHardwareBenchmark();Scalability::BenchmarkQualityLevels();只在主机和PC上有效。移动端忽高忽低不准确,可能受温度影响较大。

贴图相关命令

设置贴图的尺寸级别(精度),前提是贴图已经生成了LOD(即mipmap)

r.mipmaplodbias 0
查询命令的参数值

C++ 或者 蓝图中使用查询函数

float UKismetSystemLibrary::GetConsoleVariableFloatValue(UObject* WorldContextObject, const FString& VariableName)

int32 UKismetSystemLibrary::GetConsoleVariableIntValue(UObject* WorldContextObject, const FString& VariableName)

例如:

先在命令行执行

r.ScreenPercentage 200

然后通过蓝图或者C++查询

float RetVal = KismetSystemLibrary::GetConsoleVariableIntValue(this, TEXT("r.ScreenPercentage"));
//RetVal is 200.f

文档

Commands

Stat Commands
https://docs-origin.unrealengine.com/latest/INT/Engine/Performance/StatCommands/

Unreal Engine 4 Console Variables and Commands
https://digilander.libero.it/ZioYuri78/

Measuring Performance
https://unrealartoptimization.github.io/book/process/measuring-performance/