UGameplayStatics::UnloadStreamLevel
#include "Kismet/GameplayStatics.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintCallable
Description
Removes a previously streamed-in sub-level from the world by name, freeing its memory and actors. The latent callback fires when the unload is complete.
Caveats & Gotchas
- • Note the parameter order: LatentInfo comes before bShouldBlockOnUnload, which is the reverse of LoadStreamLevel. This inconsistency is a long-standing engine quirk and easy to get wrong.
- • Any actors or objects belonging to the unloaded level are immediately invalidated. Holding raw pointers to them after calling this function will result in dangling pointer crashes.
- • If the level was made visible before unloading, it is first hidden, then removed. The visibility change is not instant and may produce one rendered frame with partial state.
Signature
static ENGINE_API void UnloadStreamLevel(const UObject* WorldContextObject, FName LevelName, FLatentActionInfo LatentInfo, bool bShouldBlockOnUnload); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| WorldContextObject | const UObject* | Any object in the world to use as context. | — |
| LevelName | FName | The short name of the sub-level 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 streaming level after the player leaves an area C++
FLatentActionInfo LatentInfo;
LatentInfo.CallbackTarget = this;
LatentInfo.ExecutionFunction = FName("OnLevelUnloaded");
LatentInfo.Linkage = 0;
LatentInfo.UUID = 3;
UGameplayStatics::UnloadStreamLevel(this, FName("MySubLevel"), LatentInfo, false); See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?