Toggle GUI button

How does it work the GUI toggle?

I want to be able to switch between two textures if the toggle is on or off.

The GUI.Toggle is described on this page in the manual and here in the scripting reference.

If you want something to happen when toggling the toggle, here is one way to do it:

var toggleBool = true;

function OnGUI () {
    var toggleBoolNew = GUI.Toggle (Rect (25, 25, 100, 30), toggleBool, "Toggle");

    // Check if the toggle was toggled
    if (toggleBoolNew != toggleBool) {
        if (toggleBoolNew == true)
            Debug.Log("Toggle was enabled");
        else
            Debug.Log("Toggle was disabled");

        toggleBool = toggleBoolNew;
    }
}