UActorComponent::ComponentIsInLevel
#include "Components/ActorComponent.h"
Access: public
Specifiers: const
Description
Returns true if this component's owning actor is contained in the given level. Used for level-membership queries, particularly in streaming scenarios.
Caveats & Gotchas
- • Returns false if the component has no owning actor or the owning actor has no outer level, not just when the level doesn't match. Always guard against null TestLevel input.
- • This checks the actor's actual level, not the world partition grid cell. In open-world/HLOD setups the result may differ from the cell currently streamed in.
Signature
ENGINE_API bool ComponentIsInLevel(const class ULevel *TestLevel) const Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| TestLevel | const ULevel* | The level to test membership against. | — |
Return Type
bool Example
Check if a component belongs to a specific streaming level C++
ULevelStreaming* StreamingLevel = UGameplayStatics::GetStreamingLevel(this, FName("MyLevel"));
if (StreamingLevel && MyComponent->ComponentIsInLevel(StreamingLevel->GetLoadedLevel()))
{
// Component lives in MyLevel
} Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?