Save + Load State
The State API saves and loads the state of a player's gameplay, allowing a player to continue from the last saved state. This is a separate concept from Player Progress, which is a progress indicator that is displayed to the instructor.
- 1.As soon as your game is initialized, you must call load state to check for any saved state.
- 2.If valid state is available, then both New Game and Continue buttons should be visible.
- 3.Clicking Continue will resume the player with the saved state, and also report the last saved Progress increment back to the server.
- 4.Clicking New Game will start the player with default state.
While your game is required to support saving state, there is not a specific minimum requirement for save frequency. In general, we recommend that players should not lose more than 3 minutes of playtime when they exit and resume the game. If your game has sequential levels, then you should save state at the start of each level. If your game includes one or more tutorials, then you should save state before each tutorial so the player has the opportunity to review the tutorial when they resume.
If the Unity API detects that there is no player session available on the server (for example in a game preview or anonymous mode) then the state will be saved locally on the browser/device using PlayerPrefs.
Migrating saved state to a new game version is not supported at this time. If you submit a new version of your game and it is accepted and published to the LOL server, then any saved player state for the previous game version will be invalidated.
Unity developers can reference the LegendsOfLearning-Example project included in the SDK for a fully functioning example of Save + Load State. This example will be folded into the main Example Project in the next SDK version.