RealDocs

AActor::GetActorClassDefaultComponents

function Engine Since 5.0
#include "GameFramework/Actor.h"
Access: public Specifiers: static

Description

Returns all components of a given type on an actor class's CDO, including Blueprint-added components that are invisible to `GetComponents()` when called on CDO instances directly.

Caveats & Gotchas

  • Regular `GetComponents()` on a CDO misses Blueprint-constructed components because `BlueprintCreatedComponents` is populated per-instance, not on the CDO. This function specifically handles that gap by inspecting the Blueprint's component templates.
  • Returned component pointers are const template objects from the CDO — modifying them directly would corrupt the archetype. Use these for read-only inspection (e.g. checking initial values, configuration).
  • This is a static function — no actor instance is needed. It works on the class itself, making it useful for editor tools, data validation, and factory code that runs before actor spawning.

Signature

static void GetActorClassDefaultComponents(const TSubclassOf<AActor>& InActorClass, const TSubclassOf<UActorComponent>& InComponentClass, TArray<const UActorComponent*>& OutComponents)

Parameters

Name Type Description Default
InActorClass const TSubclassOf<AActor>& The actor class whose CDO to inspect.
InComponentClass const TSubclassOf<UActorComponent>& Filter: only return components of this type.
OutComponents TArray<const UActorComponent*>& Output array; previous contents are overwritten.

Return Type

void

Example

Inspect default mesh components on a Blueprint actor class C++
TArray<const UActorComponent*> MeshComps;
AActor::GetActorClassDefaultComponents(MyActorClass, UStaticMeshComponent::StaticClass(), MeshComps);
for (const UActorComponent* Comp : MeshComps)
{
    const UStaticMeshComponent* MeshComp = CastChecked<UStaticMeshComponent>(Comp);
    UE_LOG(LogTemp, Log, TEXT("Default mesh: %s"), *GetNameSafe(MeshComp->GetStaticMesh()));
}

Version History

Introduced in: 5.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.