Slate.GameLayer.DebugCanvasVisible
Slate.GameLayer.DebugCanvasVisible
#Overview
name: Slate.GameLayer.DebugCanvasVisible
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Show/Hide the debug canvas.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of Slate.GameLayer.DebugCanvasVisible is to control the visibility of the debug canvas in the Slate UI system of Unreal Engine 5. It is primarily used for debugging and development purposes, allowing developers to show or hide the debug canvas as needed.
This setting variable is mainly relied upon by the Slate UI system, specifically within the game layer management subsystem. It is also utilized by the Functional Testing module for UI screenshot tests.
The value of this variable is set through the console variable system in Unreal Engine. It is defined as an FAutoConsoleVariableRef in SGameLayerManager.cpp, which means it can be modified at runtime through the console or configuration files.
The Slate.GameLayer.DebugCanvasVisible variable interacts with the CanvasVisibility::DebugCanvasVisibilityConsoleValue, which likely determines the actual visibility state of the debug canvas.
Developers must be aware that this variable is marked with ECVF_Cheat flag, indicating it’s intended for development and debugging purposes only. It should not be used or relied upon in production builds or gameplay logic.
Best practices when using this variable include:
- Use it only during development and debugging phases.
- Ensure it’s disabled in production builds to prevent unintended debug information from being displayed to end-users.
- When conducting UI screenshot tests, consider temporarily disabling the debug canvas using this variable to ensure clean, consistent screenshots.
- Remember to restore the previous state of the variable after modifying it for testing purposes, as demonstrated in the FunctionalUIScreenshotTest class.
- Use the console command system to toggle this variable during runtime for quick debugging sessions.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Slate/SGameLayerManager.cpp:65
Scope: file
Source code excerpt:
);
static FAutoConsoleVariableRef CVarShowDebugCanvas(
TEXT("Slate.GameLayer.DebugCanvasVisible"),
CanvasVisibility::DebugCanvasVisibilityConsoleValue,
TEXT("Show/Hide the debug canvas."),
ECVF_Cheat
);
static FAutoConsoleVariableRef CVarShowPlayerCanvas(
TEXT("Slate.GameLayer.PlayerCanvasVisible"),
#Loc: <Workspace>/Engine/Source/Developer/FunctionalTesting/Private/FunctionalUIScreenshotTest.cpp:63
Scope (from outer to inner):
file
function void AFunctionalUIScreenshotTest::PrepareTest
Source code excerpt:
if (bHideDebugCanvas)
{
if (IConsoleVariable* CVarDebugCanvasVisible = IConsoleManager::Get().FindConsoleVariable(TEXT("Slate.GameLayer.DebugCanvasVisible")))
{
PreviousDebugCanvasVisible = CVarDebugCanvasVisible->GetBool();
CVarDebugCanvasVisible->Set(false);
}
}
#Loc: <Workspace>/Engine/Source/Developer/FunctionalTesting/Private/FunctionalUIScreenshotTest.cpp:136
Scope (from outer to inner):
file
function void AFunctionalUIScreenshotTest::OnScreenshotTakenAndCompared
Source code excerpt:
if (PreviousDebugCanvasVisible.IsSet())
{
if (IConsoleVariable* CVarDebugCanvasVisible = IConsoleManager::Get().FindConsoleVariable(TEXT("Slate.GameLayer.DebugCanvasVisible")))
{
CVarDebugCanvasVisible->Set(PreviousDebugCanvasVisible.GetValue());
PreviousDebugCanvasVisible.Reset();
}
}
}
#Loc: <Workspace>/Engine/Source/Developer/FunctionalTesting/Private/FunctionalUIScreenshotTest.cpp:151
Scope (from outer to inner):
file
function void AFunctionalUIScreenshotTest::EndPlay
Source code excerpt:
if (PreviousDebugCanvasVisible.IsSet())
{
if (IConsoleVariable* CVarDebugCanvasVisible = IConsoleManager::Get().FindConsoleVariable(TEXT("Slate.GameLayer.DebugCanvasVisible")))
{
CVarDebugCanvasVisible->Set(PreviousDebugCanvasVisible.GetValue());
PreviousDebugCanvasVisible.Reset();
}
}