Hi so I’ve taken Sams code directly from Git:
public IEnumerator LoadLastScene(string saveFile)
{
Dictionary<string, object> state = LoadFile(saveFile);
int buildIndex = SceneManager.GetActiveScene().buildIndex;
if (state.ContainsKey("lastSceneBuildIndex"))
{
buildIndex = (int)state["lastSceneBuildIndex"];
}
yield return SceneManager.LoadSceneAsync(buildIndex);
RestoreState(state);
}
I found his explanation unclear and I don’t understand why we’re having to load the scene twice, I know Sam mentioned that the scene would load twice from a menu or something but that didn’t make sense to me.
Any scene would be loaded once going from one to other, unless I’ve miss understood something surely there’s an alternative way of resolving this race condition without having to load every scene we transition to twice?
It has made debugging messy and I imagine it is bad for performance.