Hi everyone
I try to do a level streaming tool in c++ that is connected to editor utility widget. In this i tried to move a level dynamically by unloading it and loading it at a different place right after it was unloaded, My FLatentActionInfo callback function should be called right after the level is unloaded, I have seen a lot of posts on how to setup and use “FLatentActionInfo” but whatever i do the “ExecutionFunction” of my FLatentActionInfo is never entered and i don’t understand why.
Here is the C++ code :
void UWorldMapEditorWidget::MoveLevel(FName LevelName, int NewX, int NewY) {
TempLevelVector = FVector(NewX*LevelSizeX, NewY*LevelSizeY, 0);
TempLevelName = LevelName;
ULevelStreaming* level = UGameplayStatics::GetStreamingLevel(GetWorld(), LevelName);
if (level != nullptr) {
UE_LOG(LogTemp, Warning, TEXT("Level find"));
if (level->IsLevelVisible()) {
level->LevelTransform.SetTranslation(TempLevelVector);
UE_LOG(LogTemp, Warning, TEXT("Level Need To Be Reload"));
FLatentActionInfo info;
info.CallbackTarget = this;
info.ExecutionFunction = "LoadLevel";
info.UUID = 1;
info.Linkage = 0;
UGameplayStatics::UnloadStreamLevel(GetWorld(), TempLevelName, info, false);
}
else {
LoadLevel();
}
}
else {
UE_LOG(LogTemp, Warning, TEXT("Level failed to be find"));
}
}
void UWorldMapEditorWidget::LoadLevel() {
UE_LOG(LogTemp, Warning, TEXT("Entered LoadLevel function"));
ULevelStreaming* level = UGameplayStatics::GetStreamingLevel(GetWorld(), TempLevelName);
if(level != nullptr){
level->LevelTransform.SetTranslation(TempLevelVector);
level->SetShouldBeLoaded(true);
level->SetShouldBeVisible(true);
UE_LOG(LogTemp, Warning, TEXT("Level Loaded"));
}
}
And here is the .h :
UFUNCTION(BlueprintCallable)
void MoveLevel(FName levelName, int NewX, int NewY);
UFUNCTION(BlueprintCallable)
void LoadLevel();
I don’t know what i missed ? Thanks in advance for your time and sorry for my bad english