From 78791cfb8c7b0a6c16feedfb79fae7a6a5bd471b Mon Sep 17 00:00:00 2001 From: Jorge Ramirez Date: Sun, 11 Mar 2018 14:15:20 -0400 Subject: [PATCH] Add protection against infinite load loop This protects against an infinite loop for situations where DontDestroyOnLoad doesn't work. --- Assets/Fungus/Scripts/Components/SaveMenu.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Assets/Fungus/Scripts/Components/SaveMenu.cs b/Assets/Fungus/Scripts/Components/SaveMenu.cs index e9b397ae..207e0c15 100644 --- a/Assets/Fungus/Scripts/Components/SaveMenu.cs +++ b/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);