DevHUDs
DevHUDs
#Overview
name: DevHUDs
The value of this variable can be defined or overridden in .ini config files. 1
.ini config file referencing this setting variable.
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of DevHUDs is to provide a system for creating and managing development heads-up displays (HUDs) within the Network Prediction module of Unreal Engine 5. These HUDs are designed to assist developers in debugging and monitoring network-related aspects of their game during development.
This setting variable is primarily used within the Network Prediction plugin, which is part of Unreal Engine’s networking subsystem. Based on the callsites, it’s clear that this variable is used in the implementation of a development menu and HUD drawing system specific to network prediction features.
The value of this variable is set in the UNetworkPredictionSettingsObject class, which is likely configured through the project settings or a configuration file. It’s defined as a UPROPERTY, which means it can be edited in the Unreal Editor.
The DevHUDs variable interacts with other variables and structures such as FNetworkPredictionDevHUD and FNetworkPredictionDevHUDItem. These are used to define the structure and content of the development HUDs.
Developers should be aware that:
- This variable is intended for development use only and should not be relied upon in production builds.
- The HUDs can be configured to only appear in certain editor states (PIE or non-PIE) using the bRequirePIE and bRequireNotPIE flags.
- The system allows for multiple HUDs, including a special one for the Level Script.
Best practices when using this variable include:
- Organizing debug information into logical HUDs for easier navigation.
- Using the PIE/non-PIE flags to ensure debug information is only displayed in appropriate contexts.
- Regularly updating the HUD contents to reflect the current state of network prediction debugging needs.
- Ensuring that any performance-intensive debug operations are only performed when the corresponding HUD is active.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Plugins/Runtime/NetworkPrediction/Config/BaseNetworkPrediction.ini:3, section: [/Script/NetworkPrediction.NetworkPredictionSettingsObject]
- INI Section:
/Script/NetworkPrediction.NetworkPredictionSettingsObject
- Raw value:
(HUDName="Debug",Items=((DisplayName="Debug ON",ExecCommand="np2.debug 1",bAutoBack=False),(DisplayName="Debug OFF",ExecCommand="np2.debug 0",bAutoBack=False),(DisplayName="Debug Draw Tolerance ON",ExecCommand="np2.Debug.Tolerance 1",bAutoBack=False),(DisplayName="Debug Draw Tolerance OFF",ExecCommand="np2.debug.Tolerance 0",bAutoBack=False),(DisplayName="Dump",ExecCommand="np2.dump",bAutoBack=False,bRequirePIE=True),(DisplayName="Spawn Dummy Client",ExecCommand="serverexec Summon /NetworkPredictionExtras/Physics/NetworkPredictionExtras_PhysicsPawnDummy.NetworkPredictionExtras_PhysicsPawnDummy_c",bAutoBack=False,bRequirePIE=false),(DisplayName="Destroy Dummy Clients",ExecCommand="serverexec DestroyAll NetworkPredictionExtras_PhysicsPawnDummy_c",bAutoBack=False,bRequirePIE=false)),bRequirePIE=False,bRequireNotPIE=False)
- Is Array:
True
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/Runtime/NetworkPrediction/Source/NetworkPrediction/Private/NetworkPredictionSettings.cpp:36
Scope (from outer to inner):
file
namespace UE_NETWORK_PREDICTION
Source code excerpt:
float LastMaxY = 0.f;
TArray<FNetworkPredictionDevHUD> DevHUDs;
};
FORCENOINLINE void DrawText(FDevMenuState& State, UCanvas* Canvas, const TCHAR* Str, float& X, float& Y, bool bEnabled=true)
{
float XL = 0.f;
float YL = 0.f;
#Loc: <Workspace>/Engine/Plugins/Runtime/NetworkPrediction/Source/NetworkPrediction/Private/NetworkPredictionSettings.cpp:83
Scope (from outer to inner):
file
namespace UE_NETWORK_PREDICTION
function FORCENOINLINE void DrawDevHUD
Source code excerpt:
if (State.ActiveHUD == INDEX_NONE)
{
for (int32 idx=0; idx < State.DevHUDs.Num(); ++idx)
{
const FNetworkPredictionDevHUD& DevHUD = State.DevHUDs[idx];
const bool bEnabled = (!DevHUD.bRequireNotPIE || !GIsEditor) && (!DevHUD.bRequirePIE || GIsEditor);
DrawText(State, Canvas, *FString::Printf(TEXT("[%d] %s"), idx+1, *DevHUD.HUDName), XPos, YPos, bEnabled);
}
DrawText(State, Canvas, TEXT(" "), XPos, YPos);
DrawText(State, Canvas, TEXT("[0] HIDE Dev HUD"), XPos, YPos);
}
else if (State.DevHUDs.IsValidIndex(State.ActiveHUD))
{
const FNetworkPredictionDevHUD& DevHUD = State.DevHUDs[State.ActiveHUD];
for (int32 idx=0; idx < DevHUD.Items.Num(); ++idx)
{
const FNetworkPredictionDevHUDItem& HUDItem = DevHUD.Items[idx];
const bool bEnabled = (!HUDItem.bRequireNotPIE || !GIsEditor) && (!HUDItem.bRequirePIE || GIsEditor);
DrawText(State, Canvas, *FString::Printf(TEXT("[%d] %s"), idx+1, *HUDItem.DisplayName), XPos, YPos, bEnabled);
}
#Loc: <Workspace>/Engine/Plugins/Runtime/NetworkPrediction/Source/NetworkPrediction/Private/NetworkPredictionSettings.cpp:138
Scope (from outer to inner):
file
namespace UE_NETWORK_PREDICTION
function FORCENOINLINE void DevMenu
Source code excerpt:
}
if (State.DevHUDs.Num() <= 0)
{
const UNetworkPredictionSettingsObject* Settings = GetDefault<UNetworkPredictionSettingsObject>();
check(Settings);
State.DevHUDs = Settings->DevHUDs;
ALevelScriptActor* LevelScript = InWorld->GetLevelScriptActor();
FNetworkPredictionDevHUD& LevelScriptDevHUD = State.DevHUDs.InsertDefaulted_GetRef(0);
LevelScriptDevHUD.HUDName = TEXT("Level Script");
if (LevelScript)
{
for (TFieldIterator<UFunction> FunctionIt(LevelScript->GetClass(), EFieldIteratorFlags::ExcludeSuper); FunctionIt; ++FunctionIt)
{
UFunction* Func = *FunctionIt;
#Loc: <Workspace>/Engine/Plugins/Runtime/NetworkPrediction/Source/NetworkPrediction/Private/NetworkPredictionSettings.cpp:188
Scope (from outer to inner):
file
namespace UE_NETWORK_PREDICTION
function FORCENOINLINE void DevMenu
Source code excerpt:
else if (State.ActiveHUD == INDEX_NONE)
{
if (State.DevHUDs.IsValidIndex(Choice-1))
{
if ((!State.DevHUDs[Choice-1].bRequirePIE || GIsEditor) && (!State.DevHUDs[Choice-1].bRequireNotPIE || !GIsEditor))
{
State.ActiveHUD = Choice-1;
}
}
}
else
{
if (State.DevHUDs.IsValidIndex(State.ActiveHUD))
{
const FNetworkPredictionDevHUD& DevHUD = State.DevHUDs[State.ActiveHUD];
if (DevHUD.Items.IsValidIndex(Choice-1))
{
const FNetworkPredictionDevHUDItem& Item = DevHUD.Items[Choice-1];
if ((!Item.bRequirePIE || GIsEditor) && (!Item.bRequireNotPIE || !GIsEditor))
{
if (ULocalPlayer* LocalPlayer = InWorld->GetFirstLocalPlayerFromController())
#Loc: <Workspace>/Engine/Plugins/Runtime/NetworkPrediction/Source/NetworkPrediction/Public/NetworkPredictionSettings.h:123
Scope (from outer to inner):
file
class class UNetworkPredictionSettingsObject : public UObject
Source code excerpt:
UPROPERTY(config, EditAnywhere, Category = DevHUD, meta=(ShowOnlyInnerProperties))
TArray<FNetworkPredictionDevHUD> DevHUDs;
#if WITH_EDITOR
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
#endif
};