Navigation
API > API/Runtime > API/Runtime/Engine > API/Runtime/Engine/GameFramework
Inheritance Hierarchy
- UObjectBase
- UObjectBaseUtility
- UObject
- USaveGame
- ULocalPlayerSaveGame
References
| Module | Engine |
| Header | /Engine/Source/Runtime/Engine/Classes/GameFramework/SaveGame.h |
| Include | #include "GameFramework/SaveGame.h" |
Syntax
UCLASS (Abstract, Blueprintable, BlueprintType, MinimalAPI)
class ULocalPlayerSaveGame : public USaveGame
Remarks
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.
Variables
| Type | Name | Description | |
|---|---|---|---|
| int32 | CurrentSaveRequest | Integer that is incremented every time a save has been requested in the current session, can be used to know if one is in progress | |
| int32 | LastErrorSaveRequest | Integer that is set when a save fails | |
| int32 | LastSuccessfulSaveRequest | Integer that is set when a save completes successfully, if this equals RequestedSaveCount then the last save was successful | |
| int32 | LoadedDataVersion | The value of SavedDataVersion when a save was last loaded, this will be -1 for newly created saves | |
| TObjectPtr< const ULocalPlayer > | OwningPlayer | The local player this is connected to, can be null if subclasses override Get/Set Local Player or it hasn't been initialized | |
| int32 | SavedDataVersion | The value of GetLatestDataVersion when this was last saved. | |
| FString | SaveSlotName | The slot name this was loaded from and that will be used to save to in the future |
Functions
| Type | Name | Description | |
|---|---|---|---|
| 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. | |
| bool | AsyncLoadOrCreateSaveGameForLocalPlayer
(
TSubclassOf< ULocalPlayerSaveGame > SaveGameClass, |
Native version of above function, this takes a ULocalPlayer and calls a native delegate. | |
| bool | Asynchronously save to the slot and user index. | ||
| ULocalPlayerSaveGame * | CreateNewSaveGameForLocalPlayer
(
TSubclassOf< ULocalPlayerSaveGame > SaveGameClass, |
Create a brand new save game, possibly ready for saving but without trying to load from disk. | |
| int32 | Returns the invalid save data version, which means it has never been saved/loaded | ||
| int32 | Returns the latest save data version, this is used when the new data is saved | ||
| const ULocalPlayer * | Returns the local player this is associated with, this will be valid if it is ready to save | ||
| APlayerController * | Returns the local player controller this is associated with, this will be valid if it is ready to save | ||
| FPlatformUserId | Returns the platform user to save to, based on Local Player by default | ||
| int32 | Returns the user index to save to, based on Local Player by default | ||
| int32 | Returns the game-specific version number this was last saved/loaded as | ||
| FString | Returns the save slot name to use | ||
| void | Called after loading, this is not called for newly created saves | ||
| void | HandlePostSave
(
bool bSuccess |
Called after saving finishes with success/failure result | |
| void | Called before saving, do any game-specific fixup here | ||
| void | InitializeSaveGame
(
const ULocalPlayer* LocalPlayer, |
Initializes this save after either loading or initial creation, automatically called by load/create functions above | |
| bool | Returns true if a save is in progress | ||
| 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. | |
| 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. | |
| void | OnPostLoad () |
Blueprint event called after loading, is not called for newly created saves | |
| void | OnPostSave
(
bool bSuccess |
Blueprint event called after saving finishes with success/failure result | |
| void | OnPreSave () |
Blueprint event called before saving, do any game-specific fixup here | |
| void | Blueprint event called to reset all saved data to default, called when the load fails or manually | ||
| ULocalPlayerSaveGame * | ProcessLoadedSave
(
USaveGame* BaseSave, |
Internal helper function used by both the sync and async save | |
| void | ProcessSaveComplete
(
const FString& SlotName, |
Internal callback that will call HandlePostSave | |
| void | Resets all saved data to default values, called when the load fails or manually | ||
| bool | Synchronously save using the slot and user index, stalling the main thread until it completes. | ||
| void | SetLocalPlayer
(
const ULocalPlayer* LocalPlayer |
Associates this save game with a local player, this is called automatically during load/create | |
| void | SetSaveSlotName
(
const FString& SlotName |
Sets the save slot name for any future saves | |
| bool | Returns true if it has been saved at least once and the last save was successful | ||
| bool | WasLoaded () |
Returns true if this was loaded from an existing save | |
| bool | Returns true if a save was ever requested, may still be in progress |