Slate.EnableSlateWidgetTracker
Slate.EnableSlateWidgetTracker
#Overview
name: Slate.EnableSlateWidgetTracker
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether or not we enable the tracking of widgets via the Slate Widget Tracker.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of Slate.EnableSlateWidgetTracker is to enable or disable the tracking of widgets via the Slate Widget Tracker in Unreal Engine 5. This setting is primarily used for the Slate UI system, which is responsible for creating and managing user interfaces in the engine.
The Slate Widget Tracker is part of the SlateCore module, which is a core component of the Unreal Engine’s UI framework. This setting directly affects the functionality of the FSlateWidgetTracker class, which is responsible for tracking widgets by tags and notifying listeners when widgets of certain tags are added or removed.
The value of this variable is set through a console variable (CVarEnableSlateWidgetTracker) defined in the SlateWidgetTracker.cpp file. It is initialized with a default value of 0, meaning it is disabled by default. Developers can change this value through config files, C++, or at runtime via console commands.
This variable interacts closely with the CVarEnableSlateWidgetTracker console variable. They share the same value, and the FSlateWidgetTracker::IsEnabled() function directly checks the value of CVarEnableSlateWidgetTracker to determine if widget tracking is enabled.
Developers must be aware that enabling this variable may have performance implications, as it introduces additional overhead for tracking widgets. It should be used judiciously, especially in performance-critical scenarios or in large-scale applications with many UI elements.
Best practices when using this variable include:
- Only enable it when necessary, such as during UI development or debugging.
- Consider disabling it in shipping builds to avoid unnecessary overhead.
- Use it in conjunction with the FTrackedMetaData to add tags to widgets you want to track.
- Be mindful of the performance impact when enabled, especially in complex UI scenarios.
Regarding the associated variable CVarEnableSlateWidgetTracker:
The purpose of CVarEnableSlateWidgetTracker is to provide a runtime-configurable way to enable or disable the Slate Widget Tracker. It is implemented as a console variable, which allows for easy modification during development and debugging.
This console variable is defined in the SlateCore module and is used directly by the FSlateWidgetTracker class to determine if widget tracking should be active.
The value of CVarEnableSlateWidgetTracker is set when it’s defined, with a default value of 0 (disabled). It can be modified through console commands or programmatically at runtime.
CVarEnableSlateWidgetTracker interacts directly with the Slate.EnableSlateWidgetTracker setting, effectively controlling its behavior. The FSlateWidgetTracker::IsEnabled() function uses this variable to determine if tracking is enabled.
Developers should be aware that changes to CVarEnableSlateWidgetTracker will immediately affect the behavior of the Slate Widget Tracker. It’s important to coordinate its use with other parts of the codebase that may rely on widget tracking.
Best practices for using CVarEnableSlateWidgetTracker include:
- Use it for debugging and development purposes, toggling it on and off as needed.
- Consider exposing it in debug menus or developer consoles for easy access during testing.
- Be cautious about changing its value in shipping builds, as it may affect performance.
- Document its use and effects clearly for other team members working on the UI system.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Private/Widgets/Accessibility/SlateWidgetTracker.cpp:7
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarEnableSlateWidgetTracker(
TEXT("Slate.EnableSlateWidgetTracker"),
0,
TEXT("Whether or not we enable the tracking of widgets via the Slate Widget Tracker."),
ECVF_Default);
FSlateWidgetTracker& FSlateWidgetTracker::Get()
{
#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Public/Widgets/Accessibility/SlateWidgetTracker.h:27
Scope (from outer to inner):
file
function DECLARE_EVENT_ThreeParams
Source code excerpt:
static SLATECORE_API FSlateWidgetTracker& Get();
/** Return true if Slate.EnableSlateWidgetTracker was set to true via config files or C++. */
SLATECORE_API bool IsEnabled() const;
/** Adds a tracked Widget for the specified tags. */
SLATECORE_API void AddTrackedWidget(const SWidget* WidgetToTrack, const TArray<FName>& Tags);
/** Adds a tracked Widget for the specified tag. */
SLATECORE_API void AddTrackedWidget(const SWidget* WidgetToTrack, FName Tag);
#Associated Variable and Callsites
This variable is associated with another variable named CVarEnableSlateWidgetTracker
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Private/Widgets/Accessibility/SlateWidgetTracker.cpp:6
Scope: file
Source code excerpt:
#include "Misc/MemStack.h"
static TAutoConsoleVariable<int32> CVarEnableSlateWidgetTracker(
TEXT("Slate.EnableSlateWidgetTracker"),
0,
TEXT("Whether or not we enable the tracking of widgets via the Slate Widget Tracker."),
ECVF_Default);
FSlateWidgetTracker& FSlateWidgetTracker::Get()
#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Private/Widgets/Accessibility/SlateWidgetTracker.cpp:20
Scope (from outer to inner):
file
function bool FSlateWidgetTracker::IsEnabled
Source code excerpt:
bool FSlateWidgetTracker::IsEnabled() const
{
return CVarEnableSlateWidgetTracker->GetInt() == 1;
}
void FSlateWidgetTracker::AddTrackedWidget(const SWidget* WidgetToTrack, const TArray<FName>& Tags)
{
if (IsEnabled() && WidgetToTrack != nullptr)
{