Navigation
API > API/Runtime > API/Runtime/Engine
Abstract subclass of USaveGame that provides utility functions that let you associate a Save Game object with a specific local player. These objects can also be loaded using the functions on GameplayStatics, but you would need to call functions like InitializeSaveGame manually. For simple games, it is fine to blueprint this class directly and add parameters and override functions in blueprint, but for complicated games you will want to subclass this in native code and set up proper versioning.
| Name | ULocalPlayerSaveGame |
| Type | class |
| Header File | /Engine/Source/Runtime/Engine/Classes/GameFramework/SaveGame.h |
| Include Path | #include "GameFramework/SaveGame.h" |
Syntax
UCLASS (Abstract, Blueprintable, BlueprintType, MinimalAPI)
class ULocalPlayerSaveGame : public USaveGame
Inheritance Hierarchy
- UObjectBase → UObjectBaseUtility → UObject → USaveGame → ULocalPlayerSaveGame
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual bool AsyncSaveGameToSlotForLocalPlayer () |
Asynchronously save to the slot and user index. | GameFramework/SaveGame.h |
|
virtual int32 GetInvalidDataVersion() |
Returns the invalid save data version, which means it has never been saved/loaded | GameFramework/SaveGame.h |
|
virtual int32 GetLatestDataVersion() |
Returns the latest save data version, this is used when the new data is saved | GameFramework/SaveGame.h |
|
virtual const ULocalPlayer * GetLocalPlayer() |
Returns the local player this is associated with, this will be valid if it is ready to save | GameFramework/SaveGame.h | |
virtual APlayerController * GetLocalPlayerController() |
Returns the local player controller this is associated with, this will be valid if it is ready to save | GameFramework/SaveGame.h |
|
virtual FPlatformUserId GetPlatformUserId() |
Returns the platform user to save to, based on Local Player by default | GameFramework/SaveGame.h |
|
virtual int32 GetPlatformUserIndex() |
Returns the user index to save to, based on Local Player by default | GameFramework/SaveGame.h |
|
virtual int32 GetSavedDataVersion() |
Returns the game-specific version number this was last saved/loaded as | GameFramework/SaveGame.h |
|
virtual FString GetSaveSlotName() |
Returns the save slot name to use | GameFramework/SaveGame.h |
|
virtual void HandlePostLoad() |
Called after loading, this is not called for newly created saves | GameFramework/SaveGame.h | |
virtual void HandlePostSave
(
bool bSuccess |
Called after saving finishes with success/failure result | GameFramework/SaveGame.h | |
virtual void HandlePreSave() |
Called before saving, do any game-specific fixup here | GameFramework/SaveGame.h | |
virtual void InitializeSaveGame
(
const ULocalPlayer* LocalPlayer, |
Initializes this save after either loading or initial creation, automatically called by load/create functions above | GameFramework/SaveGame.h | |
virtual bool IsSaveInProgress() |
Returns true if a save is in progress | GameFramework/SaveGame.h |
|
void OnPostLoad() |
Blueprint event called after loading, is not called for newly created saves | GameFramework/SaveGame.h |
|
void OnPostSave
(
bool bSuccess |
Blueprint event called after saving finishes with success/failure result | GameFramework/SaveGame.h |
|
void OnPreSave() |
Blueprint event called before saving, do any game-specific fixup here | GameFramework/SaveGame.h |
|
void OnResetToDefault() |
Blueprint event called to reset all saved data to default, called when the load fails or manually | GameFramework/SaveGame.h |
|
virtual void ResetToDefault() |
Resets all saved data to default values, called when the load fails or manually | GameFramework/SaveGame.h |
|
virtual bool SaveGameToSlotForLocalPlayer () |
Synchronously save using the slot and user index, stalling the main thread until it completes. | GameFramework/SaveGame.h |
|
virtual void SetLocalPlayer
(
const ULocalPlayer* LocalPlayer |
Associates this save game with a local player, this is called automatically during load/create | GameFramework/SaveGame.h | |
virtual void SetSaveSlotName
(
const FString& SlotName |
Sets the save slot name for any future saves | GameFramework/SaveGame.h | |
virtual bool WasLastSaveSuccessful() |
Returns true if it has been saved at least once and the last save was successful | GameFramework/SaveGame.h |
|
virtual bool WasLoaded() |
Returns true if this was loaded from an existing save | GameFramework/SaveGame.h |
|
virtual bool WasSaveRequested() |
Returns true if a save was ever requested, may still be in progress | GameFramework/SaveGame.h |
|
Protected
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual void ProcessSaveComplete
(
const FString& SlotName, |
Internal callback that will call HandlePostSave | GameFramework/SaveGame.h |
Static
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
static bool AsyncLoadOrCreateSaveGameForLocalPlayer
(
TSubclassOf< ULocalPlayerSaveGame > SaveGameClass, |
Asynchronously loads a save game object in the specified slot for the local player, if this returns true the delegate will get called later. | GameFramework/SaveGame.h |
|
static bool AsyncLoadOrCreateSaveGameForLocalPlayer
(
TSubclassOf< ULocalPlayerSaveGame > SaveGameClass, |
Native version of above function, this takes a ULocalPlayer and calls a native delegate. | GameFramework/SaveGame.h | |
static ULocalPlayerSaveGame * CreateNewSaveGameForLocalPlayer
(
TSubclassOf< ULocalPlayerSaveGame > SaveGameClass, |
Create a brand new save game, possibly ready for saving but without trying to load from disk. | GameFramework/SaveGame.h | |
static ULocalPlayerSaveGame * LoadOrCreateSaveGameForLocalPlayer
(
TSubclassOf< ULocalPlayerSaveGame > SaveGameClass, |
Native version of above function, this takes a ULocalPlayer because you can have a local player before a player controller. | GameFramework/SaveGame.h | |
static ULocalPlayerSaveGame * LoadOrCreateSaveGameForLocalPlayer
(
TSubclassOf< ULocalPlayerSaveGame > SaveGameClass, |
Synchronously loads a save game object in the specified slot for the local player, stalling the main thread until it completes. | GameFramework/SaveGame.h |
|
static ULocalPlayerSaveGame * ProcessLoadedSave
(
USaveGame* BaseSave, |
Internal helper function used by both the sync and async save | GameFramework/SaveGame.h |