Save Time Button Settings in Player Prefs

I have a timer script where you can chose pre set time duration on the time with button methods like this:

//Timer Settings
	public void GoTimerSetting60Sec()
	{
		timer = 60;
	}
	
	public void GoTimerSetting5Min()
	{
		timer = 300;
	}
	
	public void GoTimerSetting10Min()
	{
		timer = 600;
	}

How would I go about saving a selected timer preset to player prefs so that the time would automatically be selected when the app is restarted?

Something like this?

public void GoTimer(int amount) {
timer = amount;
}

PlayerPrefs.SetInt("timeVar", timer); //save it like this
int a = PlayerPrefs.GetInt("timeVar"); //get it like this

You could set up PlayerPref bools for each one of these button types and then at the beginning of this script (or wherever you’re needing it) check each player pref bool, and the one that’s true, set the time to the corresponding timer bool you made.

If you go this route, make sure you set the other two to false when you mark one true.

public void GoTimerSetting60Sec(){
    timer = 60;
    timerBoolSixty = true; //Place holder bool name
    timerBoolFiveMin = false; //Place holder bool name
    timerBoolTenMin = false; //Place holder bool name
}

And etc etc.

Programming tip:
Make this all ONE function, it’s more dynamic, is easier to edit and looks better (to me at least)

public void GoTimerSetting(int time){
    timer =  time;
}

Then in your buttons’ OnClick() stuff just put in the amount in the box for the corresponding button.