Ok I have a script here that works perfectly but I want to use one button to switch cameras (Camera1, Camera2 …Camera5). I am using a ps3 controller and I want to use my Triangle button (joystick button 3) using the Input.GetAxis method which is called “Camera”. The mirrors are minimaps attached to Camera1 and Camera2 Can anyone help? Here is the original script that works and my attempt to use Input.GetAxis script:

Original script:

 var mirrorOne : GameObject;
 var mirrorTwo : GameObject;

  function Start ()
{
camSwap(1);
mirrorOne.GetComponent("Camera").enabled = true;
mirrorTwo.GetComponent("Camera").enabled = false;
}

  function Update () 
{
if(Input.GetKey("1"))
	{
	camSwap(1);
	mirrorOne.GetComponent("Camera").enabled = true;
	mirrorTwo.GetComponent("Camera").enabled = false;
	}

if(Input.GetKey("2"))
	{
	camSwap(2);
	mirrorOne.GetComponent("Camera").enabled = false;
	mirrorTwo.GetComponent("Camera").enabled = true;
	}

if(Input.GetKey("3"))
	{
	camSwap(3);
	mirrorOne.GetComponent("Camera").enabled = false;
	mirrorTwo.GetComponent("Camera").enabled = false;
	}

if(Input.GetKey("4"))
	{
	camSwap(4);
	mirrorOne.GetComponent("Camera").enabled = false;
	mirrorTwo.GetComponent("Camera").enabled = false;
	}

if(Input.GetKey("5"))
	{
	camSwap(5);
	mirrorOne.GetComponent("Camera").enabled = false;
	mirrorTwo.GetComponent("Camera").enabled = false;
	}
}

  function camSwap(currentCam : int)
{
var cameras = GameObject.FindGameObjectsWithTag("MainCamera");

for (var cams : GameObject in cameras)
	{
	cams.GetComponent(Camera).enabled = false;
	cams.GetComponent(AudioListener).enabled = false;
	}  

var oneToUse : String = "Camera"+currentCam;
gameObject.Find(oneToUse).GetComponent(Camera).enabled = true;
gameObject.Find(oneToUse).GetComponent(AudioListener).enabled = true;
}

My Attempt:

   var mirrorOne : GameObject;
   var mirrorTwo : GameObject;
   var cam : int;

    function Start ()
{
    cam = 1;
camSwap(1);
mirrorOne.GetComponent("Camera").enabled = true;
mirrorTwo.GetComponent("Camera").enabled = false;
}

   function Update () 
{
if(Input.GetAxis("Camera") && cam ==1)
	{
            cam = 2;
	camSwap(2);
	mirrorOne.GetComponent("Camera").enabled = true;
	mirrorTwo.GetComponent("Camera").enabled = false;
	}

if(Input.GetAxis("Camera") && cam ==2)
	{
            cam = 3;
	camSwap(3);
	mirrorOne.GetComponent("Camera").enabled = false;
	mirrorTwo.GetComponent("Camera").enabled = true;
	}

if(Input.GetAxis("Camera") && cam ==3)
	{
            cam = 4;
	camSwap(4);
	mirrorOne.GetComponent("Camera").enabled = false;
	mirrorTwo.GetComponent("Camera").enabled = false;
	}

if(Input.GetAxis("Camera") && cam ==4)
	{
            cam = 5;
	camSwap(5);
	mirrorOne.GetComponent("Camera").enabled = false;
	mirrorTwo.GetComponent("Camera").enabled = false;
	}

if(Input.GetAxis("Camera") && cam ==5)
	{
            cam = 1;
	camSwap(1);
	mirrorOne.GetComponent("Camera").enabled = true;
	mirrorTwo.GetComponent("Camera").enabled = false;
	}
}

    function camSwap(currentCam : int)
{
var cameras = GameObject.FindGameObjectsWithTag("MainCamera");

for (var cams : GameObject in cameras)
	{
	cams.GetComponent(Camera).enabled = false;
	cams.GetComponent(AudioListener).enabled = false;
	}  

var oneToUse : String = "Camera"+currentCam;
gameObject.Find(oneToUse).GetComponent(Camera).enabled = true;
gameObject.Find(oneToUse).GetComponent(AudioListener).enabled = true;
}

Ok I figured it out. After the first if-statement, in the Update function, the rest of the ifs need to be else-if-statements. Works perfect now. Thanx for your help though fellas.