UGameplayStatics::LoadGameFromSlot
#include "Kismet/GameplayStatics.h"
Access: public
Specifiers: static
Description
Deserialises a save file from disk and returns a USaveGame object, or null if the slot doesn't exist or loading fails. Synchronous and blocking.
Signature
static ENGINE_API USaveGame* LoadGameFromSlot(const FString& SlotName, const int32 UserIndex) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| SlotName | const FString& | The slot name used when saving. | — |
| UserIndex | int32 | Platform user index. Use 0 for single-player. | — |
Return Type
USaveGame* Caveats & Gotchas
- • Returns null if the slot doesn't exist — always check DoesSaveGameExist first or null-check the result.
- • Returns a USaveGame* — Cast to your subclass before accessing custom fields.
- • Synchronous, blocking call. Use AsyncLoadGameFromSlot for non-blocking loading on platforms where disk access is slow.
- • If the save file was created with an older version of your USaveGame class, new UPROPERTY fields will be initialised to their default values — design saves to be forward-compatible.
Example
Load with existence check C++
if (UGameplayStatics::DoesSaveGameExist(TEXT("Slot1"), 0))
{
UMyGameSave* Save = Cast<UMyGameSave>(
UGameplayStatics::LoadGameFromSlot(TEXT("Slot1"), 0)
);
if (Save)
{
ApplySaveData(Save);
}
} Tags
Version History
Introduced in: unknown
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?