- Home /
Webcam texture exception handling
Hi Guys,
I'm doing project in which I use webcam to take user's photo. In this if webcam is used by other application or not found it throws exception and some weird things happen. I want to check if exception has been thrown. I tried using try...catch clause but it didn't work. Anybody knows how to do it?
Below is my code.
var error : TextMesh;
function Start () { try { var webcamTexture : WebCamTexture = WebCamTexture();
if( !webcamTexture.isPlaying)
{
renderer.material.mainTexture = webcamTexture;
webcamTexture.Play();
print(" texture play");
}
else
error.text = " Camera not found or other application is using camera";
// Debug.Log(webcamTexture.isPlaying); } catch( err : System.Exception) { error.text = err.Message; print("from catch"); }
}
Actually unity shows it as runtime error as below
No available webcams are found. Either there is no webcam connected, or they are all in use by other applications (like Skype).
Not a solution, was stuck with this too. Did you find a workaround this problem, or how to catch the exception?
Your answer
Follow this Question
Related Questions
Webcam Support in Unity (iSight or USB Camera) 8 Answers
iPad Camera Aspect Ratio 2 Answers
How can i find max resolution for WebCamTexture 2 Answers
Adjust the exposure of phone camera manually 1 Answer
Get FOV of webcam 1 Answer