RealDocs

UAssetManager::GetPrimaryAssetIdForObject

function Engine Since unknown
#include "Engine/AssetManager.h"
Access: public Specifiers: virtualconst

Description

Checks whether the passed-in object is a registered primary asset and if so returns its id, otherwise returns an invalid FPrimaryAssetId.

Caveats & Gotchas

  • Check IsValid() on the returned FPrimaryAssetId — there's no separate success flag, an unregistered object just yields an invalid id.
  • Works by matching the object's outer package against registered asset paths, so a transient or PIE-duplicated object may not resolve even if its 'source' asset is registered.

Signature

virtual FPrimaryAssetId GetPrimaryAssetIdForObject(UObject* Object) const;

Parameters

Name Type Description Default
Object UObject* Object to test, typically an already-loaded asset.

Return Type

FPrimaryAssetId

Example

Identify a loaded asset C++
FPrimaryAssetId Id = UAssetManager::Get().GetPrimaryAssetIdForObject(MyItemAsset);
if (Id.IsValid())
{
	UE_LOG(LogTemp, Log, TEXT("Asset id: %s"), *Id.ToString());
}

Version History

Introduced in: unknown

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.