RealDocs

UGameplayStatics::UnloadStreamLevelBySoftObjectPtr

function Engine Blueprint Since 4.18
#include "Kismet/GameplayStatics.h"
Access: public Specifiers: staticUFUNCTIONBlueprintCallable

Description

Unloads a previously streamed-in sub-level identified by a soft object pointer, providing a type-safe and refactor-friendly alternative to the name-based unload.

Caveats & Gotchas

  • • If the soft object pointer is null or does not match a currently loaded streaming level, the function has no effect and the latent callback never fires — there is no error logged.
  • • Actors in the unloaded level are destroyed immediately once the unload begins. Do not cache references to them across this call.
  • • Like the name-based version, LatentInfo precedes bShouldBlockOnUnload in the parameter list — note the ordering when calling from C++.

Signature

static ENGINE_API void UnloadStreamLevelBySoftObjectPtr(const UObject* WorldContextObject, const TSoftObjectPtr<UWorld> Level, FLatentActionInfo LatentInfo, bool bShouldBlockOnUnload);

Parameters

Name Type Description Default
WorldContextObject const UObject* Any object in the world to use as context. —
Level const TSoftObjectPtr<UWorld> Soft object reference to the UWorld asset to unload. —
LatentInfo FLatentActionInfo Latent action callback that fires when the level has been fully unloaded. —
bShouldBlockOnUnload bool If true, the game thread blocks until the level is fully unloaded. —

Return Type

void

Example

Unload a level referenced by soft pointer C++
FLatentActionInfo LatentInfo;
LatentInfo.CallbackTarget = this;
LatentInfo.ExecutionFunction = FName("OnSubLevelUnloaded");
LatentInfo.Linkage = 0;
LatentInfo.UUID = 4;
UGameplayStatics::UnloadStreamLevelBySoftObjectPtr(this, SubLevelRef, LatentInfo, false);

Version History

Introduced in: 4.18

Version Status Notes
5.6 stable —

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.