Saving and Loading the Scene using PlayMaker

Examples using PlayMaker. Note that to view these examples, you will need to have purchased PlayMaker.
Post Reply
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Saving and Loading the Scene using PlayMaker

Post by Joel »

Saving and Loading the Scene using PlayMaker

This example demonstrates how you can save the last scene the player entered, and reinsert them into that scene when loading.

This does not save the contents of the scene, only the name of the scene so that they can be reinserted into it. For saving and loading the contents of a scene, please see examples such as this one:

https://moodkie.com/forum/viewtopic.php?f=17&t=1470

IMPORTANT: For this example to work, you need to add MainMenu, Scene1, Scene2 and Scene3 to the 'Scenes in build' section of File > Build Settings.

The project works as follows:
  1. You begin in the Main Menu.
  2. The 'Start New Game' button deletes any existing save data and loads the first scene of the game.
  3. The 'Load Game' button loads the last scene that the player was in. If there's no save data, this button is hidden.
  4. When you press 'Start New Game', you will enter Scene1.
  5. The 'Go to next scene' button takes you to the next scene in the game.
  6. The 'Save scene' button gets the name of the current scene and saves it.
  7. The 'Go to main menu' button takes you back to the main menu.
  8. Scene2 and Scene3 are the same, except Scene3 does not have a 'Go to next scene' button.
Notes
  • The key field on all of your Save and Load actions should be the same. For this example we use the word "CurrentScene" as the key.
  • Instead of having a save button you could instead get it to save in the Start event, depending on what you want to achieve with your project.
Attachments
Saving and Loading the Scene using PlayMaker.unitypackage
(79.13 KiB) Downloaded 345 times
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Ozbend
Posts: 1
Joined: Tue Nov 22, 2022 1:10 pm

Re: Saving and Loading the Scene using PlayMaker

Post by Ozbend »

Thanks for the example. Unfortunately there is an issue. I'm doing exactly as you did, Loading a Saved game works but New Game doesn't work. When you click on the New Game button, the save file is deleted, but for some reason it reappears when the Game scene is loaded. In general, if there is a Save, then I can't start a New Game, since the save file appears again. It only works if you stop the game and start over. Then the Save file is permanently deleted.
Please help me solve this problem.
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Saving and Loading the Scene using PlayMaker

Post by Joel »

Hi there,

Have you enabled caching? If so, you would also need to remove the file from the cache using the Delete File action with the location set to Cache.

If this isn't the issue please could you replicate this in a new project with the sample scene and private message it to me.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply