Toggle OnValueChanged ignore on start

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<UnityStandardAssets.ImageEffects.ScreenSpaceAmbientOcclusion>().enabled = ssao;
    BoolPrefs.SetBool("SSAO", ssao);
}

I have used Eric’s BoolPrefs 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<Toggle>().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?

Change the method to look like this:

public void ToggleSSAO(bool newValue) {
    ssao = newValue;
    //GetComponent...
}

Drop the Dynamic bool ToggleSSAO method in the OnValueChanged event instead of the Static Parameters ToggleSSAO. You should see no check box in the event. This way whenever the Toggle’s isOn is changed, it will also set ssao.

This is very old, which i know but somehow after googling another topic i ended up here.
For anyone else having the described problem:

Just call Toggle.SetIsOnWithoutNotify( state );