Level Streaming Issue with C++

KaylaHK
Mon, 26 Jul 2021 05:59:14 +0000
World Creation

I am trying to use C++ to do the level streaming. But for some reason, I can’t re-load the level back after unloading it.

I checked with UE_LOG and I find out that the level is “deleted” after unloading it. I can still find it in the level editor with no visibility but can’t reload it. How can I get the hidden level reloaded after unloading it ? Below is my coding.

FString AtestActor::Swap()
{
	if (bSwap)
	{


		FLatentActionInfo Info;
		//UGameplayStatics::UnloadStreamLevel(this, FName(NewLevel), Info, true);
		UGameplayStatics::UnloadStreamLevelBySoftObjectPtr(this, TestLevel, Info, true);

		UE_LOG(LogTemp, Warning, TEXT("%s"), *NewLevel);

	}

	return NewLevel;

}
FString AtestActor::OpenLevel()
{
	if (bOpenLevel)
	{
		FLatentActionInfo Info;

		//UGameplayStatics::LoadStreamLevel(this, FName(NewLevel), true, true, Info);
		UGameplayStatics::LoadStreamLevelBySoftObjectPtr(this, TestLevel, true, true, Info);
		UE_LOG(LogTemp, Warning, TEXT("%s"), *NewLevel);

	}
	return NewLevel;
}

I also find out that in the output log LogLevel: ActivateLevel /Game/UEDPIE_0_NewWorld 1 0 1 after unloading the level. Does that mean anything for the level?

1 post - 1 participant