Unreal crashes consistently when UGameplayStatics::SaveGameToSlot() is called. It’s a mobile game. The idea is to load in all the highscore times on in the beginning of play session, and distribute them to arrays in the GameInstance (just testing with level 1 here), which then are displayed in the LevelSelect widget. Then save new time to disk any time neccessary. SaveSlotName, UserIndex and savegame object pointer is stored in GameInstance class.
void UMyGameInstance::SaveLevelTimeToDisk()
{
if (SaveObject && LevelTimes.IsValidIndex(0))
{
SaveObject->time_L1 = LevelTimes[0];
UGameplayStatics::SaveGameToSlot(SaveObject, SlotName, UserIndex);
}
}
void UMyGameInstance::LoadLevelTimesFromDisk()
{
if (bIsFreshSessionStart)
{
bIsFreshSessionStart = false;
InitializeStatsArrays();
if (UGameplayStatics::DoesSaveGameExist(SlotName, UserIndex))
{
SaveObject = Cast<UMySaveGame>(UGameplayStatics::LoadGameFromSlot(SlotName, UserIndex));
LevelTimes[0] = SaveObject->time_L1;
BreakTime(LevelTimes[0], LevelTimesMinutes[0], LevelTimesSeconds[0], LevelTimesRemaining[0]);
}
else
{
SaveObject = Cast<UMySaveGame>(UGameplayStatics::CreateSaveGameObject(UMySaveGame::StaticClass()));
}
}
}
I should mention. One time out of many many crashes now, a pop up window appeared with this message: “Pure virtual function being called while application was running (GIsRunning == 1).”
It only happened once.
I would appreciate any help on this as the whole project depends on getting this working.