How do I run javascript code when a toggle is clicked?

How do I run javascript code when a toggle is clicked? what function do I have to include in my script?

if(toggle.isOn == true){
// your script
}

http://docs.unity3d.com/ScriptReference/UI.Toggle.html

I figured it out.

  1. The script has to be added to the Main Camera view.
  2. There must be a Canvas added to the Main Camera.
  3. The script variables are set up in the Start function, and triggered in the onGUI function.