0
\$\begingroup\$

I have 60+ levels in the game, that is, 60+ scenes. Let's say a player has passed to level 10 and leaves the game, then when he returns to the game , he will have to appear first on the MAIN MENU stage and then click CONTINUE and appear on stage 10. The game is on android, I tried it through PlayerPrefs, but it doesn't work for me( I just need to save the player on the current stage and then load it on the same stage where it was last time.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ What doesn't work? To load a specific scene? To save the stage the player was last? To load the playerprefs? What is your error and what have you tried? \$\endgroup\$
    – Zibelas
    Commented Aug 15, 2021 at 16:47
  • \$\begingroup\$ it doesn't work on saving or loading via PlayerPrefs, I tried to do it through a video from one guy , but he saved just variables there, not scenes \$\endgroup\$
    – MadDog
    Commented Aug 15, 2021 at 18:02
  • \$\begingroup\$ You don't want to save scenes, in your situation you probably want to save a variable (most likely an integer) that references a scene. \$\endgroup\$
    – Stefan
    Commented Aug 15, 2021 at 18:06
  • \$\begingroup\$ Yes, it will probably be easier to save a number tied to a specific scene and then load it on the basis of this number at the entrance \$\endgroup\$
    – MadDog
    Commented Aug 15, 2021 at 18:09

1 Answer 1

0
\$\begingroup\$

There are a few way you can persist data between sessions. To simply name a few you can use playerprefs or a simple file format like xml or json or custom binary files.

As a very simple example, at certain stages in your game (e.g. when a user finishes a level) you can save in a file a number associated with that level (lets say as in your case, 10). If he closes the game and relaunches it, you can load that 10 from the file in the main menu and further see what you want to do with it. (you might want to look into SceneManager.LoadScene(sceneANumber);)

Brackeys had a very nice video explaining those methods step by step if interested: https://www.youtube.com/watch?v=XOjd_qU2Ido

The last resort would be to use a package such as Easy Save 3 that provides everything needed for a save/load system, including file encryption, however it's not free.

\$\endgroup\$
1
  • \$\begingroup\$ Thank you , I'll try it now) \$\endgroup\$
    – MadDog
    Commented Aug 15, 2021 at 18:00

Not the answer you're looking for? Browse other questions tagged .