disableing script?

I have a Camera that has a script on it. I have another script, which calls out “Stats” Window. I want the camera script to be disabled until the “Stats” Window is shown. However I dont know how to access the script.
My script so far is:

var windowRect = Rect (20, 20, 120, 50);

var windowToggleKey : UnityEngine.KeyCode;
var camScript : Script;

private var winEnabled : boolean = false;

function Update () {
	if (Input.GetKeyDown(windowToggleKey)){
		winEnabled = !winEnabled;
	}
}

function OnGUI () {
	if (winEnabled) {
		camScript.enabled = !camScript.enabled;
		// Register the window.
		windowRect = GUI.Window (0, windowRect, DoMyWindow, "Stats");
	}
}

// Make the contents of the window
function DoMyWindow (windowID : int) {
// Make a very long rect that is 20 pixels tall.
// This will make the window be resizable by the top
// title bar - no matter how wide it gets.
GUI.DragWindow (Rect (0,0, 10000, 20));
}

Not sure what your problem is…? Clearly you know how to enable and disable a script… script.enable = true/false. So all you need to is just enable it when the window is up, and disable it when the window is down…

//Right here I would change it a bit.
function Update () {
   if (Input.GetKeyDown(windowToggleKey)){
      winEnabled = !winEnabled;
      camScript.enable = winEnabled;
   }
}

function OnGUI () {
   if (winEnabled) {
      //Remove the next line, in my opinion
      //camScript.enabled = !camScript.enabled;
      // Register the window.
      windowRect = GUI.Window (0, windowRect, DoMyWindow, "Stats");
   }
}

Seems you know what to do… Whats the problem again? ;). Was it the logic?

maybe I wasnt so clear on what i need :)…
anyways, the problem is that script should work, but how do I tell Unity that camScript is the one that needs to be enabled/disabled?, because Unity doesn´t know a variable type “Script”, and I have no idea on what to write instead…

I managed to solve the problem, the word I was looking for was “MonoBehaviour” :smile: