PlayerPrefs to save setActive state


I have some script that is run from my Game scene which hides a gameObject on my Menu scene. However each time the game is closed and reopened the gameObject in my Menu scene is set back to active. I want the gameObject that’s been hidden to remain hidden, even through a game reload. This is the code that I have at the moment.

		GameObject[] gameObjectArray = GameObject.FindGameObjectsWithTag ("Level2Block");
		foreach(GameObject go in gameObjectArray) {
			go.SetActive (false);
			PlayerPrefs.????? ("?????", ?????);

I use PlayerPrefs to save other information in my project, but I’m not sure how to implement it in this case, any help or advice would be much appreciated.

Try using this so you can save arrays of booleans and than set/get.

In player prefs you can only save three types of variable int, float and string. In order to save a bool i would suggest saving it as an int where if that variable is 1 the state is true and 0 it is false.

(An Example)

To set an int use PlayerPrefs.SetInt("Active" , 0)

Then to get it use PlayerPrefs.GetInt("Active") which returns the value.

A link to the documentation - Unity - Scripting API: PlayerPrefs

If you require any further assistance just ask, I hope that helps.