UGameplayStatics::GetCurrentLevelName
#include "Kismet/GameplayStatics.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintCallable
Description
Returns the name of the currently active (persistent) level. Useful for save/load systems, analytics, and conditional logic that changes behaviour based on which level is loaded.
Caveats & Gotchas
- • Returns the persistent level name, not the name of the most recently loaded streaming sub-level. If your game uses streaming levels heavily, this may not reflect what the player is currently experiencing.
- • In PIE (Play In Editor), the level name often has an editor-injected prefix (e.g. 'UEDPIE_0_MyLevel'). The bRemovePrefixString parameter strips this, but the stripping logic is heuristic and may not handle all editor prefix formats in every engine version.
- • The returned string is a short name (e.g. 'MyLevel'), not a full package path. Do not use it directly to load packages or assets.
Signature
static ENGINE_API FString GetCurrentLevelName(const UObject* WorldContextObject, bool bRemovePrefixString = true); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| WorldContextObject | const UObject* | Any object in the world to use as context. | — |
| bRemovePrefixString | bool | If true, removes any streaming- or editor-added prefix from the returned level name. | true |
Return Type
FString Example
Log the current level name C++
FString LevelName = UGameplayStatics::GetCurrentLevelName(this, true);
UE_LOG(LogGame, Log, TEXT("Current level: %s"), *LevelName); Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?