RealDocs

UAssetManager::PreloadPrimaryAssets

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

Description

Starts an async load of the given primary assets into a specific bundle state without marking them as officially Loaded. The returned handle must be kept alive or the assets are freed once loading finishes; Unload and ChangeBundleState calls do not affect them.

Caveats & Gotchas

  • Assets loaded this way are not tracked as 'Loaded' primary assets — calling UnloadPrimaryAssets or ChangeBundleStateForPrimaryAssets on the same ids has no effect on them.
  • If you drop the returned TSharedPtr<FStreamableHandle> without having separately Loaded the assets, they are freed immediately — you must hold the handle for as long as you need the data resident.
  • Prefer the FAssetManagerLoadParams overload for new code; the delegate-based overload documented here is kept mainly for compatibility with older call sites.

Signature

virtual TSharedPtr<FStreamableHandle> PreloadPrimaryAssets(
	const TArray<FPrimaryAssetId>& AssetsToLoad,
	const TArray<FName>& LoadBundles,
	bool bLoadRecursive,
	FStreamableDelegate DelegateToCall = FStreamableDelegate(),
	TAsyncLoadPriority Priority = FStreamableManager::DefaultAsyncLoadPriority,
	UE::FSourceLocation Location = UE::FSourceLocation::Current());

Parameters

Name Type Description Default
AssetsToLoad const TArray<FPrimaryAssetId>& List of primary assets to preload.
LoadBundles const TArray<FName>& Bundles to include in the preloaded state.
bLoadRecursive bool If true, recursively expands bundle references into sub-assets via RecursivelyExpandBundleData.
DelegateToCall FStreamableDelegate Delegate called when the preload completes. FStreamableDelegate()
Priority TAsyncLoadPriority Async loading priority for this request. FStreamableManager::DefaultAsyncLoadPriority
Location UE::FSourceLocation Internal call-site tracking parameter, not for direct use. UE::FSourceLocation::Current()

Return Type

TSharedPtr<FStreamableHandle>

Example

Preloading a bundle of assets C++
TArray<FPrimaryAssetId> AssetsToPreload = { FPrimaryAssetId("Weapon", "Rifle") };
PreloadHandle = UAssetManager::Get().PreloadPrimaryAssets(
	AssetsToPreload,
	{ FName("Icons") },
	/*bLoadRecursive=*/ true);
// PreloadHandle is a TSharedPtr<FStreamableHandle> member on this object;
// keep it alive for as long as the preloaded data is needed

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.