RealDocs

AActor::ContainsDataLayer

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

Description

Returns true if this actor belongs to the specified data layer asset. There is also an overload that accepts a UDataLayerInstance pointer.

Caveats & Gotchas

  • The overload taking FActorDataLayer is deprecated since UE 5.1. Convert data layers to assets using the UDataLayerToAssetCommandlet before calling this function.
  • Passing a null pointer always returns false rather than asserting — safe to call on unvalidated references, but make sure a false result is not silently masking a missing asset.

Signature

ENGINE_API bool ContainsDataLayer(const UDataLayerAsset* DataLayerAsset) const;

Parameters

Name Type Description Default
DataLayerAsset const UDataLayerAsset* The data layer asset to test for membership.

Return Type

bool

Example

Gate logic on data layer membership C++
if (MyActor->ContainsDataLayer(EnemyDataLayerAsset))
{
    // This actor is part of the enemy data layer
    RegisterWithEnemyManager(MyActor);
}

Version History

Introduced in: 5.0

Version Status Notes
5.6 stable
5.0 stable Asset-based overload introduced with World Partition.

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.