- Home /
WebcamTexture changing scenes - crash
I have object/plane that uses the WebcamTexture function. When I run by the first time the "scene A", that contains the object/plane with webcam's script, the webcam captures works fine, but if I change to a "scene B" and after get back to the "scene A", the captures doesn't work anymore. I even have to restart Unity for to make the capture works again at "scene A". Im my project I need to switch from "Scene A" to "Scene B" back to "Scene A".
Is there any function to "refresh" the webcam? I tried "DestroyImmediate" at object/plane when loading "scene B", but the problem persist.
Tks for all.
I'm having the same problem and this is the only thread I've found describing this problem.
Rodrigozol, have you found why this is happening?
I can't help you, but I'm confronted with crashes when I use webcamtextures and call Application.Quit() on windows builds. I already filed a bug report. Let's see how it turns out.
Answer by rodrigozol · Apr 23, 2013 at 04:05 PM
Benoit, I haven't found the solution. I had the same problem with Kinect's camera. So, to solve the problem, I developed the game just with one scene, with multiples scenes. It works cause it was a simple/small game.
Answer by jemonsuarez · Feb 17, 2014 at 03:47 PM
I had the same issue on webcam and the solution is calling gameObject.renderer.material.mainTexture.Stop(). I have tested with a few computers and different webcams, and it works. In a beginning I was searching for a driver problem, but not. Call Stop() and will not need to hace all in the same scene.
Answer by Emperor · Nov 23, 2016 at 09:36 PM
Just a precision from jemonsuarez's answer: you need to call stop on the webcamtexture before loading your next scene so:
webcamTexture.Stop();
Please refer to: https://docs.unity3d.com/ScriptReference/WebCamTexture.Stop.html
Hope this help anyone else stuck with this issue!
Nuance: Apparently OnDestroy is too late to Stop() the WebcamTexture successfully without causing the cited device lockout on subsequent requests. Even if you pedantically unbind all references and Destroy and null out the instance. Calling Stop() during OnDisable, however, works just fine. The $$anonymous$$ore You Know --==☆
Answer by Benoit Dufresne · Jun 27, 2013 at 11:55 AM
Make sure you use Stop() before loading a new scene. In my case I was doing it, but had a stray component using a webcam on an object I had completely forgotten about. This one I didn't Stop() and seemed to be causing the camera to stay in use until I restarted Unity.
Answer by sagaravalanche · May 05, 2018 at 10:31 AM
Did anyone find the solution for the problem. I;m currently having the same issue. Please help Thanks,Did anyone find the solution for the problem. Currently I'm facing the same issue. Please help.
Your answer
Follow this Question
Related Questions
QR-Code Decoding for iOS and Android 0 Answers
webcam texture format 0 Answers
Eyetoy Webcam not working with unity 0 Answers
Using Webcam input as a texture 2 Answers
using unity string plugin webcam 1 Answer