切換關卡
基於 UGameplayStatics::
-
OpenLevel
UGameplayStatics::OpenLevel(GetWorld(), TEXT("NewMap"));
-
OpenLevelBySoftObjectPtr
FSoftObjectPath NewMapPath(TEXT("World'/Game/CPPFunction/Interface/NewMap.NewMap'")); TSoftObjectPtr<UWorld> NewMap(NewMapPath); UGameplayStatics::OpenLevelBySoftObjectPtr(GetWorld(), NewMap);
獲取當前關卡名
-
GetCurrentLevelName
UKismetSystemLibrary::PrintString(GetWorld(), UGameplayStatics::GetCurrentLevelName(GetWorld()));
異步加載關卡
流關卡
基於 UGameplayStatics::
加載
-
UGameplayStatics::LadStreamLevel
static void LoadStreamLevel(const UObject* WorldContextObject, FName LevelName, bool bMakeVisibleAfterLoad, bool bShouldBlockOnLoad, FLatentActionInfo LatentInfo);
-
UGameplayStatics::LoadStreamLevelBySoftObjectPtr
static void LoadStreamLevelBySoftObjectPtr(const UObject* WorldContextObject, const TSoftObjectPtr<UWorld> Level, bool bMakeVisibleAfterLoad, bool bShouldBlockOnLoad, FLatentActionInfo LatentInfo);
卸載
-
UnloadStreamLevel
static void UnloadStreamLevel(const UObject* WorldContextObject, FName LevelName, FLatentActionInfo LatentInfo, bool bShouldBlockOnUnload);
-
UnloadStreamLevelBySoftObjectPtr
static void UnloadStreamLevelBySoftObjectPtr(const UObject* WorldContextObject, const TSoftObjectPtr<UWorld> Level, FLatentActionInfo LatentInfo, bool bShouldBlockOnUnload);
獲取流關卡
-
GetStreamingLevel
static class ULevelStreaming* GetStreamingLevel(const UObject* WorldContextObject, FName PackageName);
退出游戲
-
ConsoleCommand,以此類推,可以執行多種命令行
UGameplayStatics::GetPlayerController(GWorld, 0)->ConsoleCommand("quit")