AActor::PreRegisterAllComponents
#include "GameFramework/Actor.h"
Access: public
Specifiers: virtual
Description
Called before any component in the actor is registered with the world. Fires in both editor and gameplay contexts. Use it to prepare actor state that components need during their own registration.
Caveats & Gotchas
- • Called in the editor as well as at runtime, unlike PreInitializeComponents(). Code in this override must be safe to run in editor contexts — avoid gameplay-only assumptions such as a valid game mode or player controller.
- • For statically placed actors, this is called during level load before BeginPlay. For dynamically spawned actors with native root components, it is called immediately during SpawnActor. Ensure the override handles both timings.
Signature
ENGINE_API virtual void PreRegisterAllComponents(); Return Type
void Example
Prepare shared data before component registration C++
void AMyActor::PreRegisterAllComponents()
{
Super::PreRegisterAllComponents();
// Components read this during their own OnRegister:
SharedMaterial = LoadObject<UMaterialInterface>(nullptr, TEXT("/Game/Mat/M_Shared"));
} See Also
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?