Greetings fellow developers. Something has been bugging my mind lately. It’s about LevelStreamingProcess.
To make a few things clear first, i have made a function like this :
void USparked_GameInstance::Level_Streaming(FName inUnloadLevelName, FName inLoadLevelName)
{
UE_LOG(LogTemp, Warning, TEXT("Level to unload: %s , level to load: %s"), *inUnloadLevelName.ToString(), *inLoadLevelName.ToString());
Level_Load(inLoadLevelName);
Level_Unload(inUnloadLevelName);
}
As you can see, it’s a simple wrapper function to load/unload levels during runtime. It’s divided in 2 parts because i wan’t a progress bar to fill to 50% when it loads a level, and to fill to 100% when it unloads the previous level.
(During this process you see a loading screen).
Here is the unload function which gives me nightmares :
void USparked_GameInstance::Level_Unload(FName LevelName)
{
if (LevelName != "")
{
UE_LOG(LogTemp, Warning, TEXT("Unloading: %s"), *LevelName.ToString());
LevelToUnload = LevelName;
FLatentActionInfo LatentInfo;
UGameplayStatics::UnloadStreamLevel(this, LevelToUnload, LatentInfo, true);
ULevelStreaming* Unload_LevelStreaming = nullptr;
Unload_LevelStreaming = UGameplayStatics::GetStreamingLevel(this, LevelToUnload);
Unload_LevelStreaming->OnLevel
Unload_LevelStreaming->OnLevelUnloaded.AddDynamic(this, &USparked_GameInstance::Level_OnLevelUnloaded);
}
}
And the reason for that is because it never fires “OnLevelUnloaded” on the last line. (Even though it’s the same for “load function” which uses “OnLevelLoaded” which works perfectly. and fires AddDynamic delegate.
What is the matter with “OnLevelUnloaded” never firing? The level it needs to unload is pretty simple, maybe 10 boxes in total… it’s just a main menu.
Thank you for your time, this is giving me a headache.