UAssetManager::UnloadPrimaryAssetsWithType
#include "Engine/AssetManager.h"
Access: public
Specifiers: virtual
Description
Unloads every currently loaded Primary Asset of the given type in one call. Useful for bulk cleanup, such as freeing an entire asset category during cooking or a level transition.
Caveats & Gotchas
- • Only releases the reference held by the primary asset load path — assets kept alive by other hard references or a separate Load call remain resident until those are also released.
- • Calling this while gameplay is still using assets of that type causes them to be freed out from under any code holding a raw pointer instead of a handle; make sure nothing needs the type before calling.
Signature
virtual int32 UnloadPrimaryAssetsWithType(FPrimaryAssetType PrimaryAssetType); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| PrimaryAssetType | FPrimaryAssetType | Primary asset type whose loaded instances should be unloaded. | — |
Return Type
int32 Example
Free all assets of a type on level unload C++
void AMyGameMode::OnLevelUnloaded()
{
UAssetManager& Manager = UAssetManager::Get();
const FPrimaryAssetType ItemType(TEXT("Item"));
const int32 NumUnloaded = Manager.UnloadPrimaryAssetsWithType(ItemType);
UE_LOG(LogTemp, Log, TEXT("Unloaded %d item assets"), NumUnloaded);
} See Also
Tags
Version History
Introduced in: unknown
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?