save toggle code example
Example: how to save toggle values unity
public Toggle Toggle;
private void Start() {
if ((PlayerPrefs.GetInt("ToggleBool") == 1)) {
Toggle.isOn = true
}
else {
Toggle.isOn = false;
}
}
private void Update() {
if (Toggle.isOn == true) {
PlayerPrefs.SetInt("ToggleBool", 1);
}
else {
PlayerPrefs.SetInt("ToggleBool", 0);
}