@ -47,8 +47,6 @@ namespace Fungus
protected static SaveMenu instance ;
protected static SaveMenu instance ;
protected string startScene = "" ;
protected virtual void Awake ( )
protected virtual void Awake ( )
{
{
// Only one instance of SaveMenu may exist
// Only one instance of SaveMenu may exist
@ -67,17 +65,21 @@ namespace Fungus
protected virtual void Start ( )
protected virtual void Start ( )
{
{
// Assume that the first scene that contains the SaveMenu is also the scene to load on restart.
startScene = SceneManager . GetActiveScene ( ) . name ;
if ( ! saveMenuActive )
if ( ! saveMenuActive )
{
{
saveMenuGroup . alpha = 0f ;
saveMenuGroup . alpha = 0f ;
}
}
var saveManager = FungusManager . Instance . SaveManager ;
// Make a note of the current scene. This will be used when restarting the game.
if ( string . IsNullOrEmpty ( saveManager . StartScene ) )
{
saveManager . StartScene = SceneManager . GetActiveScene ( ) . name ;
}
if ( loadOnStart )
if ( loadOnStart )
{
{
var saveManager = FungusManager . Instance . SaveManager ;
if ( saveManager . SaveDataExists ( ) )
if ( saveManager . SaveDataExists ( ) )
{
{
saveManager . Load ( ) ;
saveManager . Load ( ) ;
@ -223,7 +225,9 @@ namespace Fungus
/// </summary>
/// </summary>
public virtual void Restart ( )
public virtual void Restart ( )
{
{
if ( string . IsNullOrEmpty ( startScene ) )
var saveManager = FungusManager . Instance . SaveManager ;
if ( string . IsNullOrEmpty ( saveManager . StartScene ) )
{
{
Debug . LogError ( "No start scene specified" ) ;
Debug . LogError ( "No start scene specified" ) ;
return ;
return ;
@ -232,14 +236,13 @@ namespace Fungus
PlayClickSound ( ) ;
PlayClickSound ( ) ;
// Reset the Save History for a new game
// Reset the Save History for a new game
var saveManager = FungusManager . Instance . SaveManager ;
saveManager . ClearHistory ( ) ;
saveManager . ClearHistory ( ) ;
if ( restartDeletesSave )
if ( restartDeletesSave )
{
{
saveManager . Delete ( ) ;
saveManager . Delete ( ) ;
}
}
SceneManager . LoadScene ( startScene ) ;
SceneManager . LoadScene ( saveManager . S tartScene ) ;
}
}
# endregion
# endregion