- Home /
Check if no webcam
I'm getting an "Array index is out of range" error on the if statement of the following code.
private var webCamTexture : WebCamTexture;
function Start () {
if (WebCamTexture.devices.Length > 0) {
//Get device
var deviceName = WebCamTexture.devices[0].name;
//Create web cam texture from device
webCamTexture = new WebCamTexture(deviceName, 640, 360, 30);
//Play the web cam texture
webCamTexture.Play();
//Change this objects texture to the web cam texture
renderer.material.mainTexture = webCamTexture;
}
}
I thought this would be how to check if there are no webcams on the system.
Comment