Page 3 of 5
Re: Save Scale
Posted: Tue Oct 04, 2022 5:01 pm
by Fearinhell
Ill have to make a spreadsheet and figure out what needs saved across scenes. For me it will be this scale saver and some items. Thank you for explaining this!
Re: Save Scale
Posted: Wed Oct 05, 2022 6:59 pm
by Fearinhell
Quick question, So lets say Scene 1 has Potions that need to be active state saved. I have created a MultiActiveSaver and have quite a few objects on it. It is attached to the player avatar so that as the character advances to scene 2 other items are saved for scene 2. BUT these potions are not in scene 2, will this cause an issue?
Re: Save Scale
Posted: Wed Oct 05, 2022 9:22 pm
by Tony Li
Yes. Use separate MultiActiveSavers in each scene. So scene 1's MultiActiveSaver saves the active states of the potions in scene 1, and scene 2's MultiActiveSaver saves the active states of the potions in scene 2.
Re: Save Scale
Posted: Fri Oct 21, 2022 7:53 pm
by Fearinhell
So Im using the UCC Saver and it is stored on the parent object of the player character. When the player goes from scene 1 to scene 2 and a save is done the player still starts back in scene 1. I am doing a ASync load and moving the parent object and the player character to scene 2. How can I make the player start in scene 2 when they save in scene 2?
Re: Save Scale
Posted: Fri Oct 21, 2022 10:19 pm
by Tony Li
Hi,
1. Use a different player GameObject in each scene. (This isn't absolutely required, but it makes it easier to test scenes individually.)
2. Change scenes using PixelCrushers.SaveSystem.LoadScene() in C#, or use a ScenePortal component/prefab, or add a SaveSystemMethods component to some GameObject and configure a UnityEvent to call SaveSystemMethods.LoadScene.
Note that you can specify a spawnpoint by name in the destination scene. The Save System will look for a GameObject with that name and move the player there.
Re: Save Scale
Posted: Sun Oct 23, 2022 2:58 pm
by Fearinhell
Between my scenes 1 and 2 I cant make a seperate game object, just too many variables and game objects in that tree that is required for my game.
Im using a scene transition asset for changing scenes that I really like so I guess Im going to try the save system methods component. I have attached that to the player character, do I need to put in a default starting scene name? I will just change my code in the load/continue button in menu to load. I guess my question is SaveSystemMethods will save the scene the character is in? Thanks Tony!
Re: Save Scale
Posted: Sun Oct 23, 2022 4:54 pm
by Tony Li
To change scenes using a different scene-changing asset, see the instructions in:
How To: Change Scenes With Save System
Re: Save Scale
Posted: Sun Oct 23, 2022 6:15 pm
by Fearinhell
Perfect! Thank you! Ill do some more reading and get this implemented.
Re: Save Scale
Posted: Sun Oct 23, 2022 8:16 pm
by Fearinhell
Ok lets say I have added the correct code for saving. *Might need some more tweeking. I have a game menu and a Load Game function. Also lets say scenes 1 2 and 3. The player exits at scene 2 and that saves the game to slot 0. My code looks like
public void LoadGame()
{
SaveSystem.LoadFromSlot(0);
PixelCrushers.SaveSystem.ApplySavedGameData();
//SaveSystem.LoadScene("scene");
}
So if I use the savesystem.loadscene how does it know which of the 3 scenes to load from?
Re: Save Scale
Posted: Sun Oct 23, 2022 8:29 pm
by Tony Li
Hi,
Keep the Save System component's Save Current Scene checkbox ticked.
To save your game, just use:
Code: Select all
PixelCrushers.SaveSystem.SaveToSlot(0);
To load your game, just use:
Code: Select all
PixelCrushers.SaveSystem.LoadFromSlot(0);
If you were to use the Save System's scene changer, you'd use a Scene Portal or this code:
Code: Select all
PixelCrushers.SaveSystem.LoadScene("scene-name");
However, since you're using something else to change scenes, run this code
before changing the scene:
Code: Select all
PixelCrushers.SaveSystem.RecordSavedGameData();
PixelCrushers.SaveSystem.BeforeSceneChange();
Then change the scene. After changing the scene, run this code:
Code: Select all
PixelCrushers.SaveSystem.ApplySavedGameData();