Game Development Reference
In-Depth Information
var lastLocation = PlayerPrefs.GetString(
"CurrentLocation", "Home");
NavigationManager.NavigateTo(lastLocation);
});
}
}
GUILayout.EndArea();
}
This is a very simple menu with two buttons. The first uses the NavigationManager
script to load the Home scene, and the other only displays whether there is a load available
and then performs the following operations:
1. Loads the current state of the game.
2. Once the Load delegate is complete, it also retrieves the player's last location
from PlayerPrefs .
3. Then, it navigates to the last scene the player was in.
Attach the script to the camera, save the scene, and add it to the Build settings, and we are
almost set.
The last thing to do is ensure that we save the game. You could do this by implementing it
via a pause menu in the game, but for simplicity, I just added it to the Naviga-
tionManager script to save the game whenever the player moves from scene to scene.
So, open up the NavigationManager script and add GameState.SaveState()
before the call to FadeInOutManager in both the NavigateTo and GoBack meth-
ods.
Search WWH ::




Custom Search