Scene Saving In Between Runtimes

Hi, I’m making a 3D horror-ish game that sometimes forces the game to exit.
And because of that, I need a way to save which scene the player is in
so that when the next time the game is started back up again. It will load into the scene where the player left of.

I myself have no clue how to do this, I have searched videos and google and I simply can’t find a thing on the subject.

Thanks, already.

You can save the scene in the PlayerPrefs, and then when they load the game again, just check what scene they were on.


void OnForceExit()
PlayerPrefs.SetInt("ForceQuitLevel", SceneManager.GetActiveScene().buildIndex);

void OnGameStartupOrWhatever()
if (PlayerPrefs.GetInt("ForceQuitLevel") != null)
//load the NEXT scene index here.