How do I increment a variable while reloading a scene?

The game I’m working on is a maze game with a random generator. I am trying to increase the size of the maze everytime the player reaches the end. So I have the a script for the end that reloads the stage every time that it is triggered by the Player. How do I continue to do this but also increase the size of the maze every time it goes through.

The easiest way is to use PlayerPrefs

You can just use it like so

PlayerPrefs.SetInt("maze size", PlayerPrefs.GetInt("maze size") * 2);

It is saved on disk so that next time you open the game it will be the same, so if you want it to reset on exit make sure to set it to the default when the game exits!

Also make sure to Set before you Get, otherwise, it may through an error.