Browse Source

Add protection against infinite load loop

This protects against an infinite loop for situations where DontDestroyOnLoad doesn't work.
master
Jorge Ramirez 7 years ago
parent
commit
78791cfb8c
  1. 6
      Assets/Fungus/Scripts/Components/SaveMenu.cs

6
Assets/Fungus/Scripts/Components/SaveMenu.cs

@ -58,6 +58,8 @@ namespace Fungus
protected static SaveMenu instance;
protected static bool hasLoadedOnStart = false;
protected virtual void Awake()
{
// Only one instance of SaveMenu may exist
@ -89,8 +91,10 @@ namespace Fungus
saveManager.StartScene = SceneManager.GetActiveScene().name;
}
if (loadOnStart)
if (loadOnStart && !hasLoadedOnStart)
{
hasLoadedOnStart = true;
if (saveManager.SaveDataExists(saveDataKey))
{
saveManager.Load(saveDataKey);

Loading…
Cancel
Save