UActorComponent::GetComponentLevel
#include "Components/ActorComponent.h"
Access: public
Specifiers: const
Description
Returns the ULevel that this component belongs to, determined by the owning actor's level. Returns null if the component has no owner or the owner has no level.
Caveats & Gotchas
- • Returns null if the component is not owned by an actor that is placed in a level (e.g., transient actors, CDOs, or components created outside of a world context).
- • For streaming level checks, prefer ComponentIsInLevel or ComponentIsInPersistentLevel rather than comparing the returned pointer manually, as those methods handle edge cases around level streaming persistence.
Signature
ENGINE_API ULevel* GetComponentLevel() const Return Type
ULevel* Example
Get the component's level and log its name C++
if (ULevel* Level = MyComponent->GetComponentLevel())
{
UE_LOG(LogTemp, Log, TEXT("Component is in level: %s"), *Level->GetName());
} Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?