So I have an UI.Toggle on my video settings menu that toggles a SSAO-bool and therefore enables/disables the SSAO script. I dropped the ToggleSSAO() method on OnValueChanged-field, so it gets called, when its bool "isOn" has changed.
public void ToggleSSAO(){
ssao = !ssao;
GetComponent().enabled = ssao;
BoolPrefs.SetBool("SSAO", ssao);
}
I have used Eric's [BoolPrefs][1] script that is simulating bool values to save them as ints in the PlayerPrefs class.
Anyways, at start of the game, the saved ssao-bool should initialize the ssao bool itself and the isOn bool on the UI.Toggle.
void Awake() {
ssao = BoolPrefs.GetBool("SSAO", true);
GameObject.Find("Toggle_SSAO").GetComponent().isOn = ssao;
}
The problem is that OnValueChanged() therefore gets called at the beginning of the game because of this initialization and switches the ssao-bool again, so the isOn bool is inverted. How can I resolve this?
[1]: http://wiki.unity3d.com/index.php/BoolPrefs
↧