UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SpawnActorTimer.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
5#pragma once
6
7#include "CoreMinimal.h"
8#include "HAL/PlatformTime.h"
9
10// Define that controls compilation of this feature
11#if (!UE_BUILD_SHIPPING && 1)
12#define ENABLE_SPAWNACTORTIMER 1
13#else
14#define ENABLE_SPAWNACTORTIMER 0
15#endif
16
17#if ENABLE_SPAWNACTORTIMER
18
27
35
38{
39public:
41 : bIsRecordingSpawnActorTimes(false)
42 , FrameCount(0)
43 {}
44
46 void ReportSpawnActor(FName ClassName, FName ActorName, double SpawnTime, ESpawnActorTimingType SpawnActorType);
47
50
53
55 static void SpawnActorTimerCmdFunc(const TArray<FString>& Args);
56
57private:
58
60 void Start();
62 void Stop();
64 void OutputSpawnTimings();
65
67 bool bIsRecordingSpawnActorTimes;
68
70 TArray<FSpawnActorTimingInfo> SpawnActorInfos;
71
73 TMap<FName, FSpawnActorTimingInfo> IncompleteSpawnActorMap;
74
76 int32 FrameCount;
77};
78
81{
82public:
84 : StartTime(FPlatformTime::Seconds())
85 , ClassName(InClassName)
86 , ActorName(NAME_None)
87 , SpawnActorType(InSpawnActorType)
88 {
89 }
90
92 {
94 double ElapsedTime = StopTime - StartTime;
95 FSpawnActorTimer::Get().ReportSpawnActor(ClassName, ActorName, ElapsedTime, SpawnActorType);
96 }
97
99 {
100 ActorName = InActorName;
101 }
102
103private:
105 double StartTime;
107 FName ClassName;
109 FName ActorName;
111 ESpawnActorTimingType SpawnActorType;
112};
113
114#endif // ENABLE_SPAWNACTORTIMER
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
ESpawnActorTimingType
Definition SpawnActorTimer.h:30
Definition NameTypes.h:617
Definition SpawnActorTimer.h:81
void SetActorName(FName InActorName)
Definition SpawnActorTimer.h:98
FScopedSpawnActorTimer(FName InClassName, ESpawnActorTimingType InSpawnActorType)
Definition SpawnActorTimer.h:83
~FScopedSpawnActorTimer()
Definition SpawnActorTimer.h:91
Definition SpawnActorTimer.h:38
static FSpawnActorTimer & Get()
void ReportSpawnActor(FName ClassName, FName ActorName, double SpawnTime, ESpawnActorTimingType SpawnActorType)
static void SpawnActorTimerCmdFunc(const TArray< FString > &Args)
void IncrementFrameCount()
FSpawnActorTimer()
Definition SpawnActorTimer.h:40
Definition Array.h:670
Definition UnrealString.h.inl:34
@ false
Definition radaudio_common.h:23
Definition AndroidPlatformTime.h:18
static double Seconds()
Definition AndroidPlatformTime.h:20
Definition SpawnActorTimer.h:21
FName ClassName
Definition SpawnActorTimer.h:23
double SpawnTime
Definition SpawnActorTimer.h:25