Toggle button ?

Hello. I know in unity you can use toggle buttons. I want to affect which scripts are active in another scene, how can I make it so that when "Toggle Button A" is checked script A will be active when another scene loads? To put that in context, my game will (hopefully) have a wide variaty of options(difficulty, stage layout, mode, player type, etc). Rather than make a separate scene for each possible combination, I want to make each individual option its own script and then just activate it depending on the checked buttons. I hope that makes sense, Thanks.

Another way to do it is with PlayerPrefs. In the first scene, you could use PlayerPrefs.SetInt to store whether a script in the next scene will be active or not (so the int will be either 0 or 1), and in the second scene use PlayerPrefs.GetInt to find the value:

Scene 1's script will be something like this:

var toggleBool = true;

function Update () 
{
    if (toggleBool == true && PlayerPrefs.GetInt("toggleExample") == 0)
    {
        PlayerPrefs.SetInt("toggleExample", 1);
    }
    else if (toggleBool == false && PlayerPrefs.GetInt("toggleExample") == 1)
    {
        PlayerPrefs.SetInt("toggleExample", 0);
    }
    print (PlayerPrefs.GetInt("toggleExample"));
}

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

Then the script in Scene 2 will be something like this:

function Start()
{
    if(PlayerPrefs.GetInt("toggleExample") == 1)
    {
        GetComponent(otherScript).enabled = true;
    }
    else
    {
        GetComponent(otherScript).enabled = false;
    }
}

in terms of the GetComponent(otherScript), the (otherScript) part will be the name of your script controlling the difficulty, and (if you want to use GetComponent) will be attached to the same Game Object as this script.

A good reason to use PlayerPrefs is that you can change the integer to something that's not 0 or 1, so if instead of a single toggle (which'd only be on or off) you can have a GUI toolbar (Easy/Medium/Hard). The scene 2 script would then be like this:

function Start()
{
    if(PlayerPrefs.GetInt("difficulty") ==1)
    {
        GetComponent(difficulty1).enabled = true;
        GetComponent(difficulty2).enabled = false;
        GetComponent(difficulty3).enabled = false;
    }

    if(PlayerPrefs.GetInt("difficulty") ==2)
    {
        GetComponent(difficulty1).enabled = false;
        GetComponent(difficulty2).enabled = true;
        GetComponent(difficulty3).enabled = false;
    }
    etc...
}

Another (possibly) good reason to use PlayerPrefs is that it persists even when you close the program, so when the player picks their preferences, they won't have to re-do it every time they load the game. Although if you don't want that, you could make a script that resets the preferences at startup.

Hope that helped!

You'll need to store the checkbox values on a game object that persists across scene changes then when the scene is loaded enable and disable scripts based on the values.

example:

SettingsManager script

/*
this script would be on the persistent object that is in the menu scene  
but not the gameplay scene, it will persist into the gameplay scene.
In this example this game object is named "Settings Manager" at the root
level of the menu scene
*/

var hardMode : Boolean = true;
var fastMode : Boolean = false;

function Start () {
    DontDestroyOnLoad(gameObject);
}

SceneManager script

/*
For this example the HardModeScript is on this same game object
and FastModeScript is on a different game object.
*/

var fastModeGameObject : GameObject; // set in the inspector

private var hardModeScript : HardModeScript;
private var fastModeScript : FastModeScript;

function Start () {
    hardModeScript = gameObject.GetComponent(HardModeScript);
    fastModeScript = fastModeGameObject.GetComponent(FastModeScript);

    // find the settings manager
    var settingsObject : GameObject;
    var settingsManager : SettingsManager;
    settingsObject = GameObject.Find("/Settings Manager");
    if (!settingsObject) { Debug.Log("Didnt find settings manager"); return; }
    settingsManager = settingsObject.GetComponent(SettingsManager);

    // enable/disable scripts
    hardModeScript.enabled = settingsManager.hardMode;
    fastModeScript.enabled = settingsManager.fastMode;
}

Should be enough to get you started working with this way of doing it.