private void LoadProfile() { if (!loadStarted) { SaveProfile saveProfile = new SaveProfile(profileName); GameData gameData = saveProfile.Load(); gameData.ProfileName = profileName; loadStarted = true; SceneLoader loader = new SceneLoader(loadingScene); loader.ScenesToUnload.Add(gameObject.scene.name); loader.ScenesToLoad.Add(playerScene); loader.Destination = gameData.spawnLocation; loader.GameData = gameData; try { loader.FadeScenes(); } catch (InvalidOperationException e) { loadStarted = false; } } }
private void ReloadSave() { SaveProfile saveProfile = new SaveProfile(playerUpgrades.ProfileName); GameData gameData = saveProfile.Load(); for (int i = 0; i < SceneManager.sceneCount; i++) { Scene scene = SceneManager.GetSceneAt(i); if (scene.name != playerScene) { SceneLoader loader = new SceneLoader(loadingScene); loader.ScenesToUnload.Add(playerScene); loader.ScenesToUnload.Add(scene.name); loader.ScenesToLoad.Add(playerScene); loader.Destination = gameData.spawnLocation; loader.GameData = gameData; try { loader.FadeScenes(); } catch (InvalidOperationException e) { Invoke(nameof(ReloadSave), loadSceneRetryTime); } break; } } }