Is there a simple and elegant way to get current level name?
If there is not a way out, I have to hardcoded the level name.
I only need to restart the game.
AGameMode::RestartGame() will cause crash when exit PIE.
Is there a simple and elegant way to get current level name?
If there is not a way out, I have to hardcoded the level name.
I only need to restart the game.
AGameMode::RestartGame() will cause crash when exit PIE.
So I found the only way will not crash is using UGameplayStatics::OpenLevel
It will cause problem when I change the level’s name. The problem still exists using config file.(When you forget change level name in config file it has same effect as hardcoded the level name in C++ or blueprints)
GetLevel()->GetName() may work although I’ve not tried it.
Thank you.
GetWorld()->GetName() will return the current map name.
Thank you.
GetWorld()->GetName() will return the current map name.
GetLevel()->GetName() will return “PersistentLevel”
UGamePlayStatics::OpenLevel(this, GetWorld()->GetName(), false);
But there still exists a problem by doing this to restart a level. You need to save currrent Level first. It will load the level last saved.
It can not load the level is editing but not saving it.