AActor::GetInstanceComponents
#include "GameFramework/Actor.h"
Access: public
Specifiers: const
Description
Returns a read-only reference to the array of components that have been added to this actor instance at runtime via AddInstanceComponent.
Caveats & Gotchas
- • The returned array only contains components tracked via AddInstanceComponent — it does not include native components defined in the constructor or Blueprint-created components stored in BlueprintCreatedComponents.
- • Do not cache the returned reference across frames; the underlying array can be mutated by Add/Remove/Clear calls, invalidating any cached pointer or iterator.
Signature
ENGINE_API const TArray<UActorComponent*>& GetInstanceComponents() const Return Type
const TArray<UActorComponent*>& Example
Iterate over all instance components C++
for (UActorComponent* Comp : GetInstanceComponents())
{
if (UStaticMeshComponent* Mesh = Cast<UStaticMeshComponent>(Comp))
{
Mesh->SetVisibility(false);
}
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?