[HOWTO] How To: Change Scenes With Save System

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
Tony Li
Posts: 22093
Joined: Thu Jul 18, 2013 1:27 pm

[HOWTO] How To: Change Scenes With Save System

Post by Tony Li »

When changing scenes, you can use the Pixel Crushers Save System to record the state of the old scene before leaving, and then restore the saved state of the new scene after entering. Otherwise, when you leave the old scene, you'll lose the player's progress in it; and when you enter the new scene, it will have its original design-time state without any progress that the player may have made in it.

To change scenes with the save system, use any of these techniques:
  • In C#: PixelCrushers.SaveSystem.LoadScene("sceneName") or LoadScene("sceneName@spawnpoint")
  • In a sequence: LoadLevel("sceneName") or LoadLevel("sceneName", "spawnpoint")
  • Using a Scene Portal component.
  • By calling SaveSystemMethods.LoadScene (e.g., add to a UI Button and call in OnClick() event).
If you must change scenes some other way, then before changing scenes call:

Code: Select all

PixelCrushers.SaveSystem.RecordSavedGameData();
PixelCrushers.SaveSystem.BeforeSceneChange();
After changing scenes, call:

Code: Select all

PixelCrushers.SaveSystem.ApplySavedGameData();
See also:
Post Reply