(C#) Clueless: how do I use this camera switching script ?

Hi

I have found this script in Unity’s forum for switching between two cameras, however, I’m not sure how to use it !

I thought that all I had to do was to attach the script to the two cameras I wish to switch between, but that is not what I’m supposed to do !

So now I’m utterly clueless as to what it is I have to do in order to switch between the two cameras.

using UnityEngine;
using System.Collections;

public class CamSwitchController : MonoBehaviour {


    public Camera maincamera;
    public Camera YellowCubeCamera;


    private Camera[] cameras;
    private int currentCameraIndex = 0;
    private Camera currentCamera;
	
	// Use this for initialization
    void Start()
    {
        cameras = new Camera[] { maincamera, YellowCubeCamera };//this is the array of cameras
        currentCamera = maincamera; //When the program start the main camera is selected as the default camera
        ChangeView();
    }
	
	// Update is called once per frame
    void Update()
    {
        if(Input.GetKeyDown("s"))
        {
            currentCameraIndex++;
            if (currentCameraIndex > cameras.Length-1)
                currentCameraIndex = 0;
            ChangeView();
        }
    }

    void ChangeView()
    {
        currentCamera.enabled = false;
        currentCamera = cameras[currentCameraIndex];
        currentCamera.enabled = true;
    }
}

Can anyone please point me in the right direction as I’m really stuck !

Put the script on an empty game object (or you could pick one of the cameras). Drag and drop the two cameras onto the ‘maincamera’ and ‘YellowCubeCamera’ variables in the inspector.