I need a little push in the right direction. I am now trying to save my game and I found a tutorial that was what I was looking for.
The tutorial saves and loads the game on the same scene and I totally understand it and it works. But when my game launches there is the Main Menu, then they click new game and that loads a world map. After the map my game scene loads where the player can save.
I want to be able to load the saved game from the Main Menu, skipping the map scene. The user clicks the ‘Load Button’ and it loads the level just fine and that is where I am stuck. When I push save it saves the level number. Then in the code below I load the saved file and grab the level number to load. I pass that to the LoadScene() method. It then loads the scene but now how do I replaces the current variables with the saved ones? I need a way to tell the scene that it was loaded, instead of being a new game, how can I do that?
public void loadLevel(){
Stream stream = File.Open(Application.dataPath + SAVE_FILE + FILE_EXTENSION, FileMode.Open);
BinaryFormatter bf = new BinaryFormatter();
playersData = (PlayersData)bf.Deserialize(stream);
stream.Close();
SceneManager.LoadScene(playersData.level);
}