UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
GameplayDebuggerCategory.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3
4// GAMEPLAY DEBUGGER CATEGORY
5//
6// Single category of gameplay debugger tool, responsible for gathering and presenting data.
7// Category instances are created on both server and local sides, and can use replication to
8// show server's state on client.
9//
10// It should be compiled and used only when module is included, so every category class
11// needs be placed in #if WITH_GAMEPLAY_DEBUGGER block (or WITH_GAMEPLAY_DEBUGGER_MENU when using WITH_GAMEPLAY_DEBUGGER_CORE).
12//
13//
14// Server side category :
15// - CollectData() function will be called in category having authority (server / standalone)
16// - set CollectDataInterval for adding delay between data collection, default value is 0, meaning: every tick
17// - AddTextLine() and AddShape() adds new data to replicate, both arrays are cleared before calling CollectData()
18// - SetDataPackReplication() marks struct member variable for replication
19// - MarkDataPackDirty() forces data pack replication, sometimes changes can go unnoticed (CRC based)
20//
21// Local category :
22// - DrawData() function will be called in every tick to present gathered data
23// - everything added by AddTextLine() and AddShape() will be shown before calling DrawData()
24// - CreateSceneProxy() allows creating custom scene proxies, use with MarkRenderStateDirty()
25// - OnDataPackReplicated() notifies about receiving new data, use with MarkRenderStateDirty() if needed
26// - BindKeyPress() allows creating custom key bindings active only when category is being displayed
27//
28//
29// Categories needs to be manually registered and unregistered with GameplayDebugger.
30// It's best to do it in owning module's Startup / Shutdown, similar to detail view customizations.
31// Check AIModule.cpp for examples.
32
33#pragma once
34
35#include "CoreMinimal.h"
38
39class AActor;
42class UPrimitiveComponent;
44
49{
50public:
51
54
56 GAMEPLAYDEBUGGER_API virtual void CollectData(APlayerController* OwnerPC, AActor* DebugActor);
57
60
63
66
68 GAMEPLAYDEBUGGER_API void AddTextLine(const FString& TextLine);
69
72
75
78
81
83 FName GetCategoryName() const { return CategoryName; }
84
87
89 bool IsCategoryEnabled() const { return bIsEnabled; }
90
92 bool IsCategoryLocal() const { return bIsLocal; }
93
95 bool IsCategoryAuth() const { return bHasAuthority; }
96
99
100 int32 GetNumDataPacks() const { return ReplicatedDataPacks.Num(); }
101 float GetDataPackProgress(int32 DataPackId) const { return ReplicatedDataPacks.IsValidIndex(DataPackId) ? ReplicatedDataPacks[DataPackId].GetProgress() : 0.0f; }
102 bool IsDataPackReplicating(int32 DataPackId) const { return ReplicatedDataPacks.IsValidIndex(DataPackId) && ReplicatedDataPacks[DataPackId].IsInProgress(); }
104
105 // temporary functions for compatibility, will be removed soon
106 TArray<FString> GetReplicatedLinesCopy() const { return ReplicatedLines; }
107 TArray<FGameplayDebuggerShape> GetReplicatedShapesCopy() const { return ReplicatedShapes; }
108
109protected:
119
124 static GAMEPLAYDEBUGGER_API bool IsLocationInViewCone(const FVector& ViewLocation, const FVector& ViewDirection, const FVector& TargetLocation);
125
128
131
134
138 template<typename T>
140 {
142 NewDataPack.PackId = ReplicatedDataPacks.Num();
143 NewDataPack.Flags = Flags;
144 NewDataPack.SerializeDelegate.BindRaw(DataPackAddr, &T::Serialize);
145 NewDataPack.ResetDelegate.BindLambda([=] { *DataPackAddr = T(); });
146
147 ReplicatedDataPacks.Add(NewDataPack);
148 return NewDataPack.PackId;
149 }
150
152 void ForceImmediateCollect() { LastCollectDataTime = -MAX_dbl; }
153
156
159
162
165
168
171
179
180private:
181
185
187 uint32 bIsLocal : 1;
188
190 uint32 bHasAuthority : 1;
191
193 uint32 bIsEnabled : 1;
194
196 int32 CategoryId;
197
199 double LastCollectDataTime;
200
202 FName CategoryName;
203
205 TArray<FString> ReplicatedLines;
206
208 TArray<FGameplayDebuggerShape> ReplicatedShapes;
209
211 TArray<FGameplayDebuggerDataPack> ReplicatedDataPacks;
212};
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
EGameplayDebuggerDataPack
Definition GameplayDebuggerTypes.h:237
#define MAX_dbl
Definition NumericLimits.h:31
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Actor.h:257
Definition GameplayDebuggerCategoryReplicator.h:119
Definition PlayerController.h:261
Definition DebugRenderSceneProxy.h:41
Definition GameplayDebuggerAddonBase.h:14
Definition GameplayDebuggerAddonManager.h:33
Definition GameplayDebuggerTypes.h:30
Definition GameplayDebuggerCategory.h:49
uint32 bShowUpdateTimer
Definition GameplayDebuggerCategory.h:164
virtual GAMEPLAYDEBUGGER_API void CollectData(APlayerController *OwnerPC, AActor *DebugActor)
Definition GameplayDebuggerCategory.cpp:29
GAMEPLAYDEBUGGER_API void MarkRenderStateDirty()
Definition GameplayDebuggerCategory.cpp:165
FGameplayDebuggerDataPack::FHeader GetDataPackHeaderCopy(int32 DataPackId) const
Definition GameplayDebuggerCategory.h:103
bool ShouldCollectDataOnClient() const
Definition GameplayDebuggerCategory.h:98
int32 SetDataPackReplication(T *DataPackAddr, EGameplayDebuggerDataPack Flags=EGameplayDebuggerDataPack::ResetOnTick)
Definition GameplayDebuggerCategory.h:139
bool IsDataPackReplicating(int32 DataPackId) const
Definition GameplayDebuggerCategory.h:102
bool IsCategoryLocal() const
Definition GameplayDebuggerCategory.h:92
GAMEPLAYDEBUGGER_API void AddShape(const FGameplayDebuggerShape &Shape)
Definition GameplayDebuggerCategory.cpp:59
int32 GetNumDataPacks() const
Definition GameplayDebuggerCategory.h:100
static GAMEPLAYDEBUGGER_API bool IsLocationInViewCone(const FVector &ViewLocation, const FVector &ViewDirection, const FVector &TargetLocation)
Definition GameplayDebuggerCategory.cpp:137
float GetDataPackProgress(int32 DataPackId) const
Definition GameplayDebuggerCategory.h:101
TArray< FGameplayDebuggerShape > GetReplicatedShapesCopy() const
Definition GameplayDebuggerCategory.h:107
bool ShouldDrawReplicationStatus() const
Definition GameplayDebuggerCategory.h:80
void ForceImmediateCollect()
Definition GameplayDebuggerCategory.h:152
virtual GAMEPLAYDEBUGGER_API FDebugRenderSceneProxy * CreateDebugSceneProxy(const UPrimitiveComponent *InComponent, FDebugDrawDelegateHelper *&OutDelegateHelper)
Definition GameplayDebuggerCategory.cpp:39
bool IsCategoryEnabled() const
Definition GameplayDebuggerCategory.h:89
virtual GAMEPLAYDEBUGGER_API void DrawData(APlayerController *OwnerPC, FGameplayDebuggerCanvasContext &CanvasContext)
Definition GameplayDebuggerCategory.cpp:34
bool IsCategoryAuth() const
Definition GameplayDebuggerCategory.h:95
virtual GAMEPLAYDEBUGGER_API void OnDataPackReplicated(int32 DataPackId)
Definition GameplayDebuggerCategory.cpp:46
GAMEPLAYDEBUGGER_API void DrawCategory(APlayerController *OwnerPC, FGameplayDebuggerCanvasContext &CanvasContext)
Definition GameplayDebuggerCategory.cpp:67
uint32 bShowDataPackReplication
Definition GameplayDebuggerCategory.h:161
GAMEPLAYDEBUGGER_API void MarkDataPackDirty(int32 DataPackId)
Definition GameplayDebuggerCategory.cpp:157
GAMEPLAYDEBUGGER_API void ResetReplicatedData()
Definition GameplayDebuggerCategory.cpp:183
GAMEPLAYDEBUGGER_API bool GetViewPoint(const APlayerController *OwnerPC, FVector &OutViewLocation, FVector &OutViewDirection) const
Definition GameplayDebuggerCategory.cpp:118
GAMEPLAYDEBUGGER_API void AddTextLine(const FString &TextLine)
Definition GameplayDebuggerCategory.cpp:51
uint32 bShowOnlyWithDebugActor
Definition GameplayDebuggerCategory.h:170
bool ShouldDrawCategory(bool bHasDebugActor) const
Definition GameplayDebuggerCategory.h:77
TArray< FString > GetReplicatedLinesCopy() const
Definition GameplayDebuggerCategory.h:106
GAMEPLAYDEBUGGER_API FString GetSceneProxyViewFlag() const
Definition GameplayDebuggerCategory.cpp:177
virtual GAMEPLAYDEBUGGER_API ~FGameplayDebuggerCategory()
Definition GameplayDebuggerCategory.cpp:25
FName GetCategoryName() const
Definition GameplayDebuggerCategory.h:83
GAMEPLAYDEBUGGER_API FGameplayDebuggerCategory()
Definition GameplayDebuggerCategory.cpp:10
uint32 bShowCategoryName
Definition GameplayDebuggerCategory.h:167
bool IsCategoryHeaderVisible() const
Definition GameplayDebuggerCategory.h:86
float CollectDataInterval
Definition GameplayDebuggerCategory.h:158
uint32 bAllowLocalDataCollection
Definition GameplayDebuggerCategory.h:178
Definition NameTypes.h:617
Definition Array.h:670
UE_REWRITE SizeType Num() const
Definition Array.h:1144
UE_NODEBUG UE_FORCEINLINE_HINT SizeType Add(ElementType &&Item)
Definition Array.h:2696
UE_NODEBUG UE_FORCEINLINE_HINT bool IsValidIndex(SizeType Index) const
Definition Array.h:1122
Definition DebugRenderSceneProxy.h:434
Definition GameplayDebuggerTypes.h:245
Definition GameplayDebuggerTypes.h:287
int32 PackId
Definition GameplayDebuggerTypes.h:305
FGameplayDebuggerDataPackHeader FHeader
Definition GameplayDebuggerTypes.h:288
Definition GameplayDebuggerCategoryReplicator.h:61
Definition GameplayDebuggerTypes.h:181