RealDocs

UAssetManager::GetPrimaryAssetHandle

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

Description

Returns the streamable handle tracking the load of a primary asset, so its progress can be polled or waited on. Returns the pending handle if a load is currently in flight, otherwise the current handle.

Caveats & Gotchas

  • Returns an invalid (null) TSharedPtr if the asset isn't currently loaded or loading — always check the handle before calling IsActive/WaitUntilComplete on it.
  • This just observes an existing load already tracked by the asset manager; holding the returned handle doesn't itself keep the asset loaded once the underlying load/bundle state is changed.

Signature

TSharedPtr<FStreamableHandle> GetPrimaryAssetHandle(const FPrimaryAssetId& PrimaryAssetId, bool bForceCurrent = false, TArray<FName>* Bundles = nullptr) const;

Parameters

Name Type Description Default
PrimaryAssetId const FPrimaryAssetId& Asset to get the streamable handle for.
bForceCurrent bool If true, only the already-completed current handle is returned. If false, a pending handle is returned when a load is in progress. false
Bundles TArray<FName>* Optional out array filled with the bundle state associated with the returned handle. nullptr

Return Type

TSharedPtr<FStreamableHandle>

Example

Poll a primary asset's load handle C++
UAssetManager& Manager = UAssetManager::Get();
FPrimaryAssetId AssetId(TEXT("Item"), TEXT("Sword"));
if (TSharedPtr<FStreamableHandle> Handle = Manager.GetPrimaryAssetHandle(AssetId))
{
	if (Handle->HasLoadCompleted())
	{
		// Safe to use the loaded asset now
	}
}

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.