Skip to content

Commit 0f3efaf

Browse files
Copilotkjy5
andcommitted
Add automatic scene reload after loading state
Co-authored-by: kjy5 <[email protected]>
1 parent 671feb5 commit 0f3efaf

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

Assets/Scripts/Services/StoreService.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,9 +399,8 @@ public bool LoadFromFile(string filePath)
399399
_localStorageService.SetValue(SliceNames.RIG_SLICE, savedState.RigState);
400400
_localStorageService.SetValue(SliceNames.ATLAS_SETTINGS_SLICE, savedState.AtlasSettingsState);
401401

402-
// TODO: Update the store with the loaded state
403-
// This will require dispatching actions to update each slice
404-
// For now, we've updated local storage and will need to reload the app
402+
// Note: The scene will be reloaded after this method returns to apply the loaded state.
403+
// The store will be re-initialized from the updated local storage on scene reload.
405404

406405
return true;
407406
}

Assets/Scripts/UI/ViewModels/MainViewModel.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Unity.AppUI.Redux;
77
using Unity.AppUI.UI;
88
using UnityEngine;
9+
using UnityEngine.SceneManagement;
910
using Utils.Types;
1011

1112
namespace UI.ViewModels
@@ -176,7 +177,10 @@ private void LoadStateFromFile()
176177
if (_storeService.LoadFromFile(filePath))
177178
{
178179
Debug.Log($"Scene state loaded successfully from: {filePath}");
179-
Debug.Log("Please reload the application to see the loaded state");
180+
Debug.Log("Reloading scene to apply loaded state...");
181+
182+
// Reload the scene to apply the loaded state from local storage
183+
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
180184
}
181185
else
182186
{

0 commit comments

Comments
 (0)