I use FCoreUObjectDelegates::PostLoadMapWithWorld.AddRaw bind with a function and I think it will be executed after I enter “Play” by “VR Preview” Mode,But the function has not been executed.
where u able to solve the issue?
There are a bunch of dead delegates that never get called littered around the source. Happy hunting. Sorry!
I had the same issue, very weird how this delegate isn’t called. But there’s another way that’s more reliable. This is what you do:
-
Bind a function to FWorldDelegates::OnWorldInitializedActors
FWorldDelegates::OnWorldInitializedActors.AddRaw(this, &YourClass::OnWorldInitialized); -
In the function that is bound to OnWorldInitializedActors, bind a function to OnWorldBeginPlay that you want called when a map loads/when BeginPlay is done.
void YourClass::OnWorldInitialized(const UWorld::FActorsInitializedParams& Params)
{
if (Params.World)
{
Params.World->OnWorldBeginPlay.AddRaw(this, &YourClass::FunctionToCall);
}
}
That worked for me except I had to bind using AddUObject instead of AddRaw. Thanks!
FCoreUObjectDelegates::PostLoadMapWithWorld.AddUObject(this, &UMySaveGame::OnMapLoaded); worked for me in UE 5.7
My mistake was to not save the pointer to the MySaveGame object. I was just testing around, so I didn’t bother to create a pointer variable. My OnMapLoaded function could not be called since MySaveGame object got garbage collected after calling UGameplayStatics::OpenLevel(). ![]()