I experimented a simplier example related to our team project "Courtroom Cahoots" with switching/swapping multiple cameras. Here's the script I used:
function Update () {
if(Input.GetMouseButton(0)){
Debug.Log("Using Camera One");
camSwap(1);
}
if(Input.GetMouseButton(1)){
Debug.Log("Using Camera Two");
camSwap(2);
}
if(Input.GetMouseButton(2)){
Debug.Log("Using Camera Three");
camSwap(3);
}
}
function camSwap(currentCam : int){
var cameras = GameObject.FindGameObjectsWithTag("cam");
for (var cams : GameObject in cameras){
cams.GetComponent(Camera).enabled = false;
}
var oneToUse : String = "Camera"+currentCam;
gameObject.Find(oneToUse).GetComponent(Camera).enabled = true;
}
Only problem with this script, it can switch up to a max of three cameras assigned to separate keys or mouse buttons. Can't go beyond three at a time. In our project, we're using more than 20 cameras and having major issues accessing all of them to make our game "work." Wish there was a simplier way to do. I know I'm on the right track, but this is where everything's on a complete hault as of right now.