toggleing the mouse visibility

(note: I barely get by with scripting and dont know what alot of things mean, so you may have to go into more detail if i ask) I was wondering if i could use a button to toggle the visibility of the mouse. I am using the First Person Controller Prefab, and i've added in the mouse look script Screen.showCursor = false; right after the void update and the mouse is gone. now i just recently realized that the mouse look script is not in java. i was wondering is there anyway i can use a different java sheet to say something like (and this is not a working java script at all, its just a very VERY rough example)

var Toggleme:boolean;

if(Input.GetButtonDown(“button here”))

{

if(Toggleme = true}

{

Toggleme = false;

}

else

{

Toggleme = true;

}

}

and then say some where that if that var is true, then run the mouse look script, so the mouse will be gone and moving the mouse controls looking, but if you hit the button again, it will be false and the mouse will appear, and moving the mouse will only allow you to click some things on the GUI and not move the screen. if someone could please write down the java script and/or explain how it works and stuff then please do

There are 2 mouse look scripts that come with your first person controller. You would have to turn on/off both.

If you want to toggle mouse visibility and mouselook then try the following:

private var fpcMouse;
private var camMouse;

function Start () {

fpcMouse = gameObject.Find("First Person Controller").GetComponent("MouseLook");
camMouse = gameObject.Find("Main Camera").GetComponent("MouseLook");

}

function Update () {

if (Input.GetButtonDown ("Fire2")) {
    Screen.showCursor = !Screen.showCursor;
    fpcMouse.enabled = !fpcMouse.enabled;
    camMouse.enabled = !camMouse.enabled;
     }

}

basically you should add 2 statements to your script.

void Update ()
{
if (Input.GetButtonDown("some button here"))
{
Screen.showCursor=!Screen.showCursor; //if true it will become not(true)=false and if false it will become true
this.enabled=!Screen.showCursor; //this is a reference to current script. you should add this
//to mouse look script to work. if this is another script then you should use GetComponent    
}

you should use GetComponent like this

var ml=GetComponent("MouseLook");

then you should use ml.enabled rather than this.enabled. if the MouseLook is in another gameObject use what sebas provided with your GameObject name.

basically you should add 2 statements to your script.

void Update ()
{
if (Input.GetButtonDown("some button here"))
{
Screen.showCursor=!Screen.showCursor; //if true it will become not(true)=false and if false it will become true
this.enabled=!Screen.showCursor; //this is a reference to current script. you should add this
//to mouse look script to work. if this is another script then you should use GetComponent    
}

you should use GetComponent like this

var ml=GetComponent("MouseLook");

then you should use ml.enabled rather than this.enabled. if the MouseLook is in another gameObject use what sebas provided with your GameObject name.