I'm initializing with this code:
WebCamDevice[] devices = WebCamTexture.devices;
string deviceName = devices[0].name;
WebCamTexture wct = new WebCamTexture(deviceName, Constants.BACKGROUND_WIDTH * 2, Constants.BACKGROUND_HEIGHT * 2, 20);
backgroundSprite.renderer.material.mainTexture = wct;
wct.Play();
And the rest of the code:
void TakeSnapshot() {
Texture2D snap = new Texture2D(wct.width, wct.height);
snap.SetPixels(wct.GetPixels());
snap.Apply();
AppManager.Singleton.SetPictureTaken(snap);
}
private void onSnapAction() {
wct.Pause();
TakeSnapshot();
wct.Stop();
DestroyObject(backgroundSprite);
DestroyObject(wct);
}
Now when I try to reload my scene, it crashes. I'm thinking it's because the camera doesn't get released somehow.
I'm also using vuforia after I've taken a picture, but that crashes the app. However, when I'm using my front camera to take a picture and my backcamera to do imagetracking it works fine. (Until I'm accessing the camera's again).
Thanks in advance.
Upgrading my Unity worked.
That's great to hear, and thanks for keeping us updated :)
N