Switch device camera.

I am using WebCamTexture class to open camera from device. I want to switch camera from front to back and vice versa in between the game play. Can anybody help?

Hey you can switch camera using webcamtexture.deviceName. Try this code:

WebCamTexture webCamTexture;
WebCamDevice[] devices;

void Start() 
{
    devices = WebCamTexture.devices;
    webCamTexture = new WebCamTexture();
    webCamTexture.deviceName = devices[0].name;
    webCamTexture.Play();
}

void OnGUI()
{
      if( GUI.Button( new Rect(0,0,100,100), "switch" ))
      {
	  webCamTexture.Stop();
	  webCamTexture.deviceName = (webCamTexture.deviceName == devices[0].name) ? devices[1].name : devices[0].name;
	  webCamTexture.Play();

      }
}

Tap switch button to switch camera…