Hello, I have multiple buttons in a menu panel where a player can choose out of the options. All buttons have the same script on them & I am trying to save its bool value. So that each time the scene is returned the bool is saved.
public Color col1, col2;
public bool chosen;
public Button[] btns;
public AudioSource click;
void Start()
{
click = GetComponent<AudioSource>();
chosen = (Playerprefs.GetInt("Chosen") != 0);
}
public void Selected()
{
click.Play();
chosen = true;
GetComponent<Image>().color = col1;
for (int i = 0; i < btns.Length; i++)
{
btns*.GetComponent<Image>().color = col2;*
btns*.GetComponent().chosen = false;*
}
PlayerPrefs.SetInt(“Chosen”, (chosen ? 1 : 0));
}